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

feat: support bundle size tunning with dropMessageCompiler option #2352

Merged
merged 1 commit into from
Aug 30, 2023
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
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