Skip to content

Commit

Permalink
fix: tree shaking optimaization (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
kazupon authored Sep 25, 2020
1 parent b9acd3d commit 9a68b1f
Show file tree
Hide file tree
Showing 34 changed files with 8,631 additions and 4 deletions.
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

0 comments on commit 9a68b1f

Please sign in to comment.