@intlify/unplugin-vue-i18n 0.11.0 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -6
- package/lib/index.cjs +21 -5
- package/lib/index.mjs +21 -5
- package/lib/types.d.ts +1 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
unplugin for Vue I18n
|
|
9
9
|
|
|
10
10
|
## 🌟 Features
|
|
11
|
+
|
|
11
12
|
- i18n resource pre-compilation
|
|
12
13
|
- i18n custom block
|
|
13
14
|
- i18n resource definition
|
|
@@ -84,14 +85,11 @@ export default defineNuxtConfig({
|
|
|
84
85
|
|
|
85
86
|
## 🚀 Usage
|
|
86
87
|
|
|
87
|
-
###
|
|
88
|
-
|
|
89
|
-
Since `vue-i18n@v9.x`, the locale messages are handled with message compiler, which converts them to javascript functions after compiling. After compiling, message compiler converts them into javascript functions, which can improve the performance of the application.
|
|
88
|
+
### locale messages pre-compilation
|
|
90
89
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
If you are using the runtime version, you will need to compile before importing locale messages by managing them in a file such as `.json`.
|
|
90
|
+
Since `vue-i18n@v9.x`, the locale messages are handled with message compiler, which transform them to javascript functions or AST objects after compiling, so these can improve the performance of the application.
|
|
94
91
|
|
|
92
|
+
If you want to maximize the performance of vue-i18n, we recommend using unplugin-vue-i18n for locale messages.
|
|
95
93
|
|
|
96
94
|
### i18n custom block
|
|
97
95
|
|
|
@@ -241,7 +239,9 @@ If you want type definition of `@intlify/unplugin-vue-i18n/messages`, add `unplu
|
|
|
241
239
|
|
|
242
240
|
|
|
243
241
|
## 📦 Automatic bundling
|
|
242
|
+
|
|
244
243
|
### For Vue I18n
|
|
244
|
+
|
|
245
245
|
As noted [here](https://vue-i18n.intlify.dev/guide/installation.html#explanation-of-different-builds), NPM provides many different builds of Vue I18n.
|
|
246
246
|
|
|
247
247
|
This plugin will automatically select and bundle Vue I18n build according to the following behavior:
|
|
@@ -345,6 +345,22 @@ This plugin will automatically select and bundle `petite-vue-i18n` build accordi
|
|
|
345
345
|
|
|
346
346
|
If you fetch some resources from the backend, the data **must be pre-compiled** for production. exmaple is [here](https://github.com/intlify/vue-i18n-next/tree/master/examples/backend).
|
|
347
347
|
|
|
348
|
+
### `jitCompilation`
|
|
349
|
+
|
|
350
|
+
- **Type:** `boolean`
|
|
351
|
+
- **Default:** `false`
|
|
352
|
+
|
|
353
|
+
Whether locale mesages should be compiled by JIT (Just in Time) compilation with vue-i18n's message compiler.
|
|
354
|
+
|
|
355
|
+
> ⚠️ NOTE:
|
|
356
|
+
This option works with vue-i18n v9.3 and later.
|
|
357
|
+
|
|
358
|
+
JIT compilation has been supported since vue-i18n v9.3. This means that since v9 was released until now, the message compiler compiles to executable JavaScript code, however it did not work in the CSP environment. Also, since this was an AOT (Ahead of Time) compilation, it was not possible to dynamically retrieve locale messages from the back-end Database and compose locale mesages with programatic.
|
|
359
|
+
|
|
360
|
+
> ⚠️ NOTE:
|
|
361
|
+
Enabling JIT compilation causes the message compiler to generate AST objects for locale mesages instead of JavaScript code. If you pre-compile locale messages with a tool such as the [Intlify CLI](https://github.com/intlify/cli) and import them dynamically, you need to rebuild that resource.
|
|
362
|
+
|
|
363
|
+
About JIT compilation, See [here](https://vue-i18n.intlify.dev/guide/advanced/optimization.html#jit-compilation)
|
|
348
364
|
|
|
349
365
|
### `runtimeOnly`
|
|
350
366
|
|
package/lib/index.cjs
CHANGED
|
@@ -121,6 +121,8 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
121
121
|
debug("bridge", bridge);
|
|
122
122
|
const runtimeOnly = shared.isBoolean(options.runtimeOnly) ? options.runtimeOnly : true;
|
|
123
123
|
debug("runtimeOnly", runtimeOnly);
|
|
124
|
+
const jitCompilation = !!options.jitCompilation;
|
|
125
|
+
debug("jitCompilation", jitCompilation);
|
|
124
126
|
const compositionOnly = installedPkg === "vue-i18n" ? shared.isBoolean(options.compositionOnly) ? options.compositionOnly : true : true;
|
|
125
127
|
debug("compositionOnly", compositionOnly);
|
|
126
128
|
const fullInstall = installedPkg === "vue-i18n" ? shared.isBoolean(options.fullInstall) ? options.fullInstall : true : false;
|
|
@@ -214,6 +216,10 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
214
216
|
debug(
|
|
215
217
|
`set __VUE_I18N_FULL_INSTALL__ is '${config.define["__VUE_I18N_FULL_INSTALL__"]}'`
|
|
216
218
|
);
|
|
219
|
+
config.define["__INTLIFY_JIT_COMPILATION__"] = jitCompilation;
|
|
220
|
+
debug(
|
|
221
|
+
`set __INTLIFY_JIT_COMPILATION__ is '${config.define["__INTLIFY_JIT_COMPILATION__"]}'`
|
|
222
|
+
);
|
|
217
223
|
config.define["__VUE_I18N_PROD_DEVTOOLS__"] = false;
|
|
218
224
|
},
|
|
219
225
|
configResolved(config) {
|
|
@@ -269,6 +275,7 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
269
275
|
strictMessage,
|
|
270
276
|
escapeHtml,
|
|
271
277
|
bridge,
|
|
278
|
+
jit: jitCompilation,
|
|
272
279
|
exportESM: esm,
|
|
273
280
|
forceStringify
|
|
274
281
|
}
|
|
@@ -285,7 +292,8 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
285
292
|
return;
|
|
286
293
|
return {
|
|
287
294
|
code: generatedCode,
|
|
288
|
-
|
|
295
|
+
// prettier-ignore
|
|
296
|
+
map: jitCompilation ? { mappings: "" } : sourceMap ? map : { mappings: "" }
|
|
289
297
|
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
290
298
|
};
|
|
291
299
|
} else {
|
|
@@ -435,6 +443,7 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
435
443
|
strictMessage,
|
|
436
444
|
escapeHtml,
|
|
437
445
|
bridge,
|
|
446
|
+
jit: jitCompilation,
|
|
438
447
|
exportESM: esm,
|
|
439
448
|
forceStringify
|
|
440
449
|
}
|
|
@@ -451,7 +460,8 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
451
460
|
return;
|
|
452
461
|
return {
|
|
453
462
|
code: generatedCode,
|
|
454
|
-
|
|
463
|
+
// prettier-ignore
|
|
464
|
+
map: jitCompilation ? { mappings: "" } : sourceMap ? map : { mappings: "" }
|
|
455
465
|
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
456
466
|
};
|
|
457
467
|
}
|
|
@@ -474,6 +484,7 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
474
484
|
isGlobal: globalSFCScope,
|
|
475
485
|
useClassComponent,
|
|
476
486
|
bridge,
|
|
487
|
+
jit: jitCompilation,
|
|
477
488
|
strictMessage,
|
|
478
489
|
escapeHtml,
|
|
479
490
|
exportESM: esm,
|
|
@@ -499,7 +510,8 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
499
510
|
return;
|
|
500
511
|
return {
|
|
501
512
|
code: generatedCode,
|
|
502
|
-
|
|
513
|
+
// prettier-ignore
|
|
514
|
+
map: jitCompilation ? { mappings: "" } : sourceMap ? map : { mappings: "" }
|
|
503
515
|
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
504
516
|
};
|
|
505
517
|
}
|
|
@@ -546,7 +558,8 @@ async function generateBundleResources(resources, query, isProduction, {
|
|
|
546
558
|
exportESM = true,
|
|
547
559
|
strictMessage = true,
|
|
548
560
|
escapeHtml = false,
|
|
549
|
-
useClassComponent = false
|
|
561
|
+
useClassComponent = false,
|
|
562
|
+
jit = false
|
|
550
563
|
}) {
|
|
551
564
|
const codes = [];
|
|
552
565
|
for (const res of resources) {
|
|
@@ -559,6 +572,7 @@ async function generateBundleResources(resources, query, isProduction, {
|
|
|
559
572
|
isGlobal,
|
|
560
573
|
useClassComponent,
|
|
561
574
|
bridge,
|
|
575
|
+
jit,
|
|
562
576
|
exportESM,
|
|
563
577
|
strictMessage,
|
|
564
578
|
escapeHtml,
|
|
@@ -620,7 +634,8 @@ function getOptions(filename, isProduction, query, sourceMap, {
|
|
|
620
634
|
useClassComponent = false,
|
|
621
635
|
allowDynamic = false,
|
|
622
636
|
strictMessage = true,
|
|
623
|
-
escapeHtml = false
|
|
637
|
+
escapeHtml = false,
|
|
638
|
+
jit = false
|
|
624
639
|
}) {
|
|
625
640
|
const mode = isProduction ? "production" : "development";
|
|
626
641
|
const baseOptions = {
|
|
@@ -633,6 +648,7 @@ function getOptions(filename, isProduction, query, sourceMap, {
|
|
|
633
648
|
strictMessage,
|
|
634
649
|
escapeHtml,
|
|
635
650
|
bridge,
|
|
651
|
+
jit,
|
|
636
652
|
exportESM,
|
|
637
653
|
env: mode,
|
|
638
654
|
onWarn: (msg) => {
|
package/lib/index.mjs
CHANGED
|
@@ -117,6 +117,8 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
117
117
|
debug("bridge", bridge);
|
|
118
118
|
const runtimeOnly = isBoolean(options.runtimeOnly) ? options.runtimeOnly : true;
|
|
119
119
|
debug("runtimeOnly", runtimeOnly);
|
|
120
|
+
const jitCompilation = !!options.jitCompilation;
|
|
121
|
+
debug("jitCompilation", jitCompilation);
|
|
120
122
|
const compositionOnly = installedPkg === "vue-i18n" ? isBoolean(options.compositionOnly) ? options.compositionOnly : true : true;
|
|
121
123
|
debug("compositionOnly", compositionOnly);
|
|
122
124
|
const fullInstall = installedPkg === "vue-i18n" ? isBoolean(options.fullInstall) ? options.fullInstall : true : false;
|
|
@@ -210,6 +212,10 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
210
212
|
debug(
|
|
211
213
|
`set __VUE_I18N_FULL_INSTALL__ is '${config.define["__VUE_I18N_FULL_INSTALL__"]}'`
|
|
212
214
|
);
|
|
215
|
+
config.define["__INTLIFY_JIT_COMPILATION__"] = jitCompilation;
|
|
216
|
+
debug(
|
|
217
|
+
`set __INTLIFY_JIT_COMPILATION__ is '${config.define["__INTLIFY_JIT_COMPILATION__"]}'`
|
|
218
|
+
);
|
|
213
219
|
config.define["__VUE_I18N_PROD_DEVTOOLS__"] = false;
|
|
214
220
|
},
|
|
215
221
|
configResolved(config) {
|
|
@@ -265,6 +271,7 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
265
271
|
strictMessage,
|
|
266
272
|
escapeHtml,
|
|
267
273
|
bridge,
|
|
274
|
+
jit: jitCompilation,
|
|
268
275
|
exportESM: esm,
|
|
269
276
|
forceStringify
|
|
270
277
|
}
|
|
@@ -281,7 +288,8 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
281
288
|
return;
|
|
282
289
|
return {
|
|
283
290
|
code: generatedCode,
|
|
284
|
-
|
|
291
|
+
// prettier-ignore
|
|
292
|
+
map: jitCompilation ? { mappings: "" } : sourceMap ? map : { mappings: "" }
|
|
285
293
|
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
286
294
|
};
|
|
287
295
|
} else {
|
|
@@ -431,6 +439,7 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
431
439
|
strictMessage,
|
|
432
440
|
escapeHtml,
|
|
433
441
|
bridge,
|
|
442
|
+
jit: jitCompilation,
|
|
434
443
|
exportESM: esm,
|
|
435
444
|
forceStringify
|
|
436
445
|
}
|
|
@@ -447,7 +456,8 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
447
456
|
return;
|
|
448
457
|
return {
|
|
449
458
|
code: generatedCode,
|
|
450
|
-
|
|
459
|
+
// prettier-ignore
|
|
460
|
+
map: jitCompilation ? { mappings: "" } : sourceMap ? map : { mappings: "" }
|
|
451
461
|
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
452
462
|
};
|
|
453
463
|
}
|
|
@@ -470,6 +480,7 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
470
480
|
isGlobal: globalSFCScope,
|
|
471
481
|
useClassComponent,
|
|
472
482
|
bridge,
|
|
483
|
+
jit: jitCompilation,
|
|
473
484
|
strictMessage,
|
|
474
485
|
escapeHtml,
|
|
475
486
|
exportESM: esm,
|
|
@@ -495,7 +506,8 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
495
506
|
return;
|
|
496
507
|
return {
|
|
497
508
|
code: generatedCode,
|
|
498
|
-
|
|
509
|
+
// prettier-ignore
|
|
510
|
+
map: jitCompilation ? { mappings: "" } : sourceMap ? map : { mappings: "" }
|
|
499
511
|
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
500
512
|
};
|
|
501
513
|
}
|
|
@@ -542,7 +554,8 @@ async function generateBundleResources(resources, query, isProduction, {
|
|
|
542
554
|
exportESM = true,
|
|
543
555
|
strictMessage = true,
|
|
544
556
|
escapeHtml = false,
|
|
545
|
-
useClassComponent = false
|
|
557
|
+
useClassComponent = false,
|
|
558
|
+
jit = false
|
|
546
559
|
}) {
|
|
547
560
|
const codes = [];
|
|
548
561
|
for (const res of resources) {
|
|
@@ -555,6 +568,7 @@ async function generateBundleResources(resources, query, isProduction, {
|
|
|
555
568
|
isGlobal,
|
|
556
569
|
useClassComponent,
|
|
557
570
|
bridge,
|
|
571
|
+
jit,
|
|
558
572
|
exportESM,
|
|
559
573
|
strictMessage,
|
|
560
574
|
escapeHtml,
|
|
@@ -616,7 +630,8 @@ function getOptions(filename, isProduction, query, sourceMap, {
|
|
|
616
630
|
useClassComponent = false,
|
|
617
631
|
allowDynamic = false,
|
|
618
632
|
strictMessage = true,
|
|
619
|
-
escapeHtml = false
|
|
633
|
+
escapeHtml = false,
|
|
634
|
+
jit = false
|
|
620
635
|
}) {
|
|
621
636
|
const mode = isProduction ? "production" : "development";
|
|
622
637
|
const baseOptions = {
|
|
@@ -629,6 +644,7 @@ function getOptions(filename, isProduction, query, sourceMap, {
|
|
|
629
644
|
strictMessage,
|
|
630
645
|
escapeHtml,
|
|
631
646
|
bridge,
|
|
647
|
+
jit,
|
|
632
648
|
exportESM,
|
|
633
649
|
env: mode,
|
|
634
650
|
onWarn: (msg) => {
|
package/lib/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlify/unplugin-vue-i18n",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.1",
|
|
4
4
|
"description": "unplugin for Vue I18n",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "kazuya kawaguchi",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@intlify/bundle-utils": "^
|
|
30
|
-
"@intlify/shared": "9.3.0-beta.
|
|
29
|
+
"@intlify/bundle-utils": "^7.0.0",
|
|
30
|
+
"@intlify/shared": "9.3.0-beta.20",
|
|
31
31
|
"@rollup/pluginutils": "^5.0.2",
|
|
32
32
|
"@vue/compiler-sfc": "^3.2.47",
|
|
33
33
|
"debug": "^4.3.3",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"json5": "^2.2.3",
|
|
37
37
|
"pathe": "^1.0.0",
|
|
38
38
|
"picocolors": "^1.0.0",
|
|
39
|
-
"source-map": "0.
|
|
39
|
+
"source-map-js": "^1.0.2",
|
|
40
40
|
"unplugin": "^1.1.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|