Skip to content

Commit 417af83

Browse files
authored
feat: support bundle size tunning with dropMessageCompiler option (#2352)
1 parent e4b4d3e commit 417af83

File tree

9 files changed

+124
-161
lines changed

9 files changed

+124
-161
lines changed

docs/content/3.options/7.bundle.md

+16-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Bundle options.
77
## `bundle`
88

99
- type: `object`
10-
- default: `{ compositionOnly: true, runtimeOnly: false, fullInstall: true }`
10+
- default: `{ compositionOnly: true, runtimeOnly: false, fullInstall: true, dropMessageCompiler: false }`
1111

1212
Configure the bundling optimization for nuxt i18n module.
1313

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

4545
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)
46+
47+
### `dropMessageCompiler`
48+
49+
- type: `boolean`
50+
- default: `false`
51+
52+
Whether to tree-shake message compiler when we will be bundling.
53+
54+
::alert{type="info"}
55+
If you will use this option, you need to enable `compilation.jit` option.
56+
::
57+
58+
::alert{type="warning"}
59+
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.
60+
::

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@
7676
}
7777
},
7878
"dependencies": {
79-
"@intlify/shared": "9.3.0-beta.26",
80-
"@intlify/unplugin-vue-i18n": "^0.12.2",
79+
"@intlify/shared": "9.3.0-beta.27",
80+
"@intlify/unplugin-vue-i18n": "^0.13.0",
8181
"@mizchi/sucrase": "^4.1.0",
8282
"@nuxt/kit": "^3.7.0",
8383
"@vue/compiler-sfc": "^3.3.4",
@@ -95,7 +95,7 @@
9595
"ufo": "^1.3.0",
9696
"unplugin": "^1.3.2",
9797
"unstorage": "^1.9.0",
98-
"vue-i18n": "9.3.0-beta.26",
98+
"vue-i18n": "9.3.0-beta.27",
9999
"vue-i18n-routing": "^0.13.4"
100100
},
101101
"devDependencies": {

playground/nuxt.config.ts

+3
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ export default defineNuxtConfig({
115115
strictMessage: false,
116116
escapeHtml: true
117117
},
118+
bundle: {
119+
// dropMessageCompiler: true
120+
},
118121
langDir: 'locales',
119122
lazy: true,
120123
baseUrl: 'http://localhost:3000',

0 commit comments

Comments
 (0)