Skip to content

Commit

Permalink
feat: support bundle size tunning with dropMessageCompiler option (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
kazupon committed Aug 30, 2023
1 parent e4b4d3e commit 417af83
Show file tree
Hide file tree
Showing 9 changed files with 124 additions and 161 deletions.
17 changes: 16 additions & 1 deletion docs/content/3.options/7.bundle.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Bundle options.
## `bundle`

- type: `object`
- default: `{ compositionOnly: true, runtimeOnly: false, fullInstall: true }`
- default: `{ compositionOnly: true, runtimeOnly: false, fullInstall: true, dropMessageCompiler: false }`

Configure the bundling optimization for nuxt i18n module.

Expand Down Expand Up @@ -43,3 +43,18 @@ When you will enable this option, vue-i18n message compiler is not bundled. This
- default: `true`

Whether to install the full set of APIs, components, etc. By default, all of them will be installed. If `false` is specified, buld-in components (`i18n-t`, `i18n-d` and `i18n-n`) and directive (`v-t`) will not be installed in vue and will be tree-shaken. For more details, See [here](https://vue-i18n.intlify.dev/guide/advanced/optimization.html#reduce-bundle-size-with-feature-build-flags)

### `dropMessageCompiler`

- type: `boolean`
- default: `false`

Whether to tree-shake message compiler when we will be bundling.

::alert{type="info"}
If you will use this option, you need to enable `compilation.jit` option.
::

::alert{type="warning"}
If you enable this option, **you should check resources in your application are pre-compiled with nuxt i18n module**. If you will be loading resources dynamically from the back-end via the API, enabling this option do not work because there is not message compiler.
::
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@
}
},
"dependencies": {
"@intlify/shared": "9.3.0-beta.26",
"@intlify/unplugin-vue-i18n": "^0.12.2",
"@intlify/shared": "9.3.0-beta.27",
"@intlify/unplugin-vue-i18n": "^0.13.0",
"@mizchi/sucrase": "^4.1.0",
"@nuxt/kit": "^3.7.0",
"@vue/compiler-sfc": "^3.3.4",
Expand All @@ -95,7 +95,7 @@
"ufo": "^1.3.0",
"unplugin": "^1.3.2",
"unstorage": "^1.9.0",
"vue-i18n": "9.3.0-beta.26",
"vue-i18n": "9.3.0-beta.27",
"vue-i18n-routing": "^0.13.4"
},
"devDependencies": {
Expand Down
3 changes: 3 additions & 0 deletions playground/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ export default defineNuxtConfig({
strictMessage: false,
escapeHtml: true
},
bundle: {
// dropMessageCompiler: true
},
langDir: 'locales',
lazy: true,
baseUrl: 'http://localhost:3000',
Expand Down
Loading

0 comments on commit 417af83

Please sign in to comment.