Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: tree shaking optimaization #125

Merged
merged 1 commit into from
Sep 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
},
"scripts": {
"benchmark": "yarn build && node ./benchmark/index.js",
"build": "node ./scripts/build.js",
"build": "yarn clean:cache:rollup && node ./scripts/build.js",
"build:sourcemap": "yarn build --sourcemap",
"build:type": "yarn build --types && tail -n +14 src/vue.d.ts >> ./dist/vue-i18n.d.ts",
"build:watch": "tsc -p . --watch",
Expand All @@ -105,6 +105,7 @@
"clean:cache:rollup": "rm -rf ./node_modules/.rts2_cache",
"clean:cache:jest": "jest --clearCache",
"clean:coverage": "rm -rf ./coverage",
"clean:size": "rm -rf ./size-check/**/dist ./size-check/**/node_modules",
"clean:dist": "rm -rf ./dist/**",
"clean:docs": "rm -rf ./docs",
"clean:type": "rm -rf ./types/** ./temp ./dist/vue-i18n.d.ts",
Expand Down
12 changes: 12 additions & 0 deletions size-check/basic/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title></title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>
17 changes: 17 additions & 0 deletions size-check/basic/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "basic",
"private": true,
"version": "0.0.0",
"scripts": {
"dev": "vite",
"build": "vite build --config vite.config.ts --mode production --minify false"
},
"dependencies": {
"vue": "^3.0.0",
"vue-i18n": "link:../.."
},
"devDependencies": {
"vite": "^1.0.0-rc.4",
"@vue/compiler-sfc": "^3.0.0"
}
}
18 changes: 18 additions & 0 deletions size-check/basic/src/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<template>
<form>
<label>{{ $t('language') }}</label>
<select v-model="$i18n.locale">
<option value="en">en</option>
<option value="ja">ja</option>
</select>
</form>
</template>

<script lang="ts">
import { defineComponent } from 'vue'

export default defineComponent({
name: 'App'
})
</script>

3 changes: 3 additions & 0 deletions size-check/basic/src/locales/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"language": "Languages"
}
3 changes: 3 additions & 0 deletions size-check/basic/src/locales/ja.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"language": "言語"
}
15 changes: 15 additions & 0 deletions size-check/basic/src/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { createApp } from 'vue'
import { createI18n } from 'vue-i18n'
import App from './App.vue'
import en from './locales/en.json'
import ja from './locales/ja.json'

const i18n = createI18n({
locale: 'en',
messages: {
en,
ja
}
})

createApp(App).use(i18n).mount('#app')
15 changes: 15 additions & 0 deletions size-check/basic/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { resolve } from 'path'
import { BuildConfig } from 'vite'

const config: BuildConfig = {
minify: false,
rollupInputOptions: {
input: resolve(__dirname, './src/main.js'),
external: ['vue'],
treeshake: {
moduleSideEffects: false
}
}
}

export default config
Loading