@intlify/unplugin-vue-i18n 3.0.1 → 5.0.0-beta.0
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 +9 -51
- package/lib/index.cjs +25 -164
- package/lib/index.d.cts +0 -1
- package/lib/index.d.mts +0 -1
- package/lib/index.d.ts +0 -1
- package/lib/index.mjs +27 -164
- package/lib/types.d.cts +0 -8
- package/lib/types.d.mts +0 -8
- package/lib/types.d.ts +0 -8
- package/lib/vite.cjs +0 -2
- package/lib/vite.d.cts +0 -1
- package/lib/vite.d.mts +0 -1
- package/lib/vite.d.ts +0 -1
- package/lib/vite.mjs +0 -2
- package/lib/webpack.cjs +0 -2
- package/lib/webpack.d.cts +0 -1
- package/lib/webpack.d.mts +0 -1
- package/lib/webpack.d.ts +0 -1
- package/lib/webpack.mjs +0 -2
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -353,13 +353,11 @@ This plugin will automatically select and bundle `petite-vue-i18n` build accordi
|
|
|
353
353
|
- **Default:** `true`
|
|
354
354
|
|
|
355
355
|
> [!IMPORTANT]
|
|
356
|
-
'jitCompilation' option
|
|
356
|
+
'jitCompilation' option is deprected in v5.
|
|
357
|
+
This option will be supported with vue-i18n until v9 latest version.
|
|
357
358
|
|
|
358
359
|
Whether locale mesages should be compiled by JIT (Just in Time) compilation with vue-i18n's message compiler.
|
|
359
360
|
|
|
360
|
-
> [!NOTE]
|
|
361
|
-
This option works with vue-i18n v9.3 and later.
|
|
362
|
-
|
|
363
361
|
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.
|
|
364
362
|
|
|
365
363
|
> [!WARNING]
|
|
@@ -376,6 +374,9 @@ Whether to tree-shake message compiler when we will be bundling.
|
|
|
376
374
|
|
|
377
375
|
If do you will use this option, you need to enable `jitCompilation` option.
|
|
378
376
|
|
|
377
|
+
> [NOTE]
|
|
378
|
+
> After v5 or later, this option can be set with or without `jitCompilation`.
|
|
379
|
+
|
|
379
380
|
> [!NOTE]
|
|
380
381
|
This option works with vue-i18n v9.3 and later.
|
|
381
382
|
|
|
@@ -539,53 +540,6 @@ If do you will use this option, you need to enable `jitCompilation` option.
|
|
|
539
540
|
</i18n>
|
|
540
541
|
```
|
|
541
542
|
|
|
542
|
-
### `bridge`
|
|
543
|
-
|
|
544
|
-
- **Type:** `boolean`
|
|
545
|
-
- **Default:** `false`
|
|
546
|
-
|
|
547
|
-
> [!WARNING]
|
|
548
|
-
'bridge' option is deprecated, sinece Vue 2 was EOL on 2023. that option will be removed in 4.0.`
|
|
549
|
-
|
|
550
|
-
The mode to birdge the i18n custom block to work in both vue-i18n@v8.x and vue-i18n@v9.x environments.
|
|
551
|
-
|
|
552
|
-
To support in a smooth transition from vue-i18n@v8.x to vue-i18n@v9.x, we provide a mode that bundles the i18n custom block to be available in either version.
|
|
553
|
-
|
|
554
|
-
> [!WARNING]
|
|
555
|
-
Note that if you set `bridge: true`, the bundle size will increase. It is recommended to disable this mode after the migration from vue-i18n@v8.26 to vue-i18n@v9.x is completed.
|
|
556
|
-
|
|
557
|
-
### `legacy`
|
|
558
|
-
|
|
559
|
-
- **Type:** `boolean`
|
|
560
|
-
- **Default:** `false`
|
|
561
|
-
|
|
562
|
-
> [!WARNING]
|
|
563
|
-
'legacy' option is deprecated, sinece Vue 2 was EOL on 2023. that option will be removed in 4.0.`
|
|
564
|
-
|
|
565
|
-
This option supports Vue I18n v8.x compatibility for resources in i18n custom blocks.
|
|
566
|
-
|
|
567
|
-
> [!NOTE]
|
|
568
|
-
To work for Vue 2.7, the value of `vueVersion` must be set to `'v2.7'`.
|
|
569
|
-
|
|
570
|
-
### `vueVersion`
|
|
571
|
-
|
|
572
|
-
- **Type:** `string`
|
|
573
|
-
- **Default:** `undefined`
|
|
574
|
-
|
|
575
|
-
> [!WARNING]
|
|
576
|
-
'vueVersion' option is deprecated, sinece Vue 2 was EOL on 2023. that option will be removed in 4.0.`
|
|
577
|
-
|
|
578
|
-
The version of Vue that will be used by Vue I18n. This option is enabled when the `legacy` option is `true`.
|
|
579
|
-
|
|
580
|
-
Available values are `'v2.6'` and `'v2.7'`.
|
|
581
|
-
|
|
582
|
-
### `esm`
|
|
583
|
-
|
|
584
|
-
- **Type:** `boolean`
|
|
585
|
-
- **Default:** `true`
|
|
586
|
-
|
|
587
|
-
For `bridge` option is `true`, whether to bundle locale resources with ESM. By default ESM, if you need to bundl with commonjs for especialy webpack, you need to set `false`
|
|
588
|
-
|
|
589
543
|
### `useClassComponent`
|
|
590
544
|
|
|
591
545
|
- **Type:** `boolean`
|
|
@@ -593,6 +547,10 @@ If do you will use this option, you need to enable `jitCompilation` option.
|
|
|
593
547
|
|
|
594
548
|
This option that to use i18n custom blocks in `vue-class-component`.
|
|
595
549
|
|
|
550
|
+
> [!IMPORTANT]
|
|
551
|
+
'useClassComponent' option is deprecated in v5.
|
|
552
|
+
This option will be supported with vue-i18n until v9 latest version.
|
|
553
|
+
|
|
596
554
|
### `onlyLocales`
|
|
597
555
|
|
|
598
556
|
- **Type:** `string | string[]`
|
package/lib/index.cjs
CHANGED
|
@@ -10,8 +10,6 @@ const shared = require('@intlify/shared');
|
|
|
10
10
|
const pluginutils = require('@rollup/pluginutils');
|
|
11
11
|
const bundleUtils = require('@intlify/bundle-utils');
|
|
12
12
|
const compilerSfc = require('@vue/compiler-sfc');
|
|
13
|
-
const JSON5 = require('json5');
|
|
14
|
-
const yaml = require('js-yaml');
|
|
15
13
|
const fs = require('fs');
|
|
16
14
|
const pc = require('picocolors');
|
|
17
15
|
|
|
@@ -19,8 +17,6 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
|
|
|
19
17
|
|
|
20
18
|
const createDebug__default = /*#__PURE__*/_interopDefaultCompat(createDebug);
|
|
21
19
|
const fg__default = /*#__PURE__*/_interopDefaultCompat(fg);
|
|
22
|
-
const JSON5__default = /*#__PURE__*/_interopDefaultCompat(JSON5);
|
|
23
|
-
const yaml__default = /*#__PURE__*/_interopDefaultCompat(yaml);
|
|
24
20
|
const pc__default = /*#__PURE__*/_interopDefaultCompat(pc);
|
|
25
21
|
|
|
26
22
|
function parseVueRequest(id) {
|
|
@@ -61,29 +57,6 @@ function parseVueRequest(id) {
|
|
|
61
57
|
};
|
|
62
58
|
}
|
|
63
59
|
|
|
64
|
-
function createBridgeCodeGenerator(source, query) {
|
|
65
|
-
return () => {
|
|
66
|
-
const data = convert(source, query.lang);
|
|
67
|
-
let value = JSON.parse(data);
|
|
68
|
-
if (shared.isString(query.locale)) {
|
|
69
|
-
value = Object.assign({}, { [query.locale]: value });
|
|
70
|
-
}
|
|
71
|
-
return JSON.stringify(value).replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029").replace(/\\/g, "\\\\").replace(/\u0027/g, "\\u0027");
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
function convert(source, lang) {
|
|
75
|
-
switch (lang) {
|
|
76
|
-
case "yaml":
|
|
77
|
-
case "yml":
|
|
78
|
-
const data = yaml__default.load(source);
|
|
79
|
-
return JSON.stringify(data, void 0, " ");
|
|
80
|
-
case "json5":
|
|
81
|
-
return JSON.stringify(JSON5__default.parse(source));
|
|
82
|
-
default:
|
|
83
|
-
return source;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
60
|
function warn(...args) {
|
|
88
61
|
console.warn(pc__default.yellow(pc__default.bold(`[unplugin-vue-i18n] `)), ...args);
|
|
89
62
|
}
|
|
@@ -101,11 +74,6 @@ const INTLIFY_BUNDLE_IMPORT_ID = "@intlify/unplugin-vue-i18n/messages";
|
|
|
101
74
|
const VIRTUAL_PREFIX = "\0";
|
|
102
75
|
const debug = createDebug__default("unplugin-vue-i18n");
|
|
103
76
|
const installedPkg = bundleUtils.checkInstallPackage("@intlify/unplugin-vue-i18n", debug);
|
|
104
|
-
const installedVueI18nBridge = bundleUtils.checkVueI18nBridgeInstallPackage(debug);
|
|
105
|
-
const vueI18nVersion = bundleUtils.getVueI18nVersion(debug);
|
|
106
|
-
if (vueI18nVersion === "8") {
|
|
107
|
-
warn(`vue-i18n@8 is not supported, since sinece Vue 2 was EOL on 2023.`);
|
|
108
|
-
}
|
|
109
77
|
const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
110
78
|
debug("plugin options:", options, meta.framework);
|
|
111
79
|
if (!["vite", "webpack"].includes(meta.framework)) {
|
|
@@ -130,32 +98,9 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
130
98
|
const forceStringify = !!options.forceStringify;
|
|
131
99
|
const defaultSFCLang = shared.isString(options.defaultSFCLang) ? options.defaultSFCLang : "json";
|
|
132
100
|
const globalSFCScope = !!options.globalSFCScope;
|
|
133
|
-
const useClassComponent = !!options.useClassComponent;
|
|
134
|
-
const bridge = !!options.bridge;
|
|
135
|
-
debug("bridge", bridge);
|
|
136
|
-
if (bridge) {
|
|
137
|
-
warn(
|
|
138
|
-
`'bridge' option is deprecated, since Vue 2 was EOL on 2023. that option will be removed in 4.0.`
|
|
139
|
-
);
|
|
140
|
-
}
|
|
141
|
-
const legacy = !!options.legacy;
|
|
142
|
-
debug("legacy", legacy);
|
|
143
|
-
if (legacy) {
|
|
144
|
-
warn(
|
|
145
|
-
`'legacy' option is deprecated, since Vue 2 was EOL on 2023. that option will be removed in 4.0.`
|
|
146
|
-
);
|
|
147
|
-
}
|
|
148
|
-
const vueVersion = shared.isString(options.vueVersion) ? options.vueVersion : void 0;
|
|
149
|
-
if (vueVersion) {
|
|
150
|
-
warn(
|
|
151
|
-
`'vueVersion' option is deprecated, since Vue 2 was EOL on 2023. that option will be removed in 4.0.`
|
|
152
|
-
);
|
|
153
|
-
}
|
|
154
101
|
const runtimeOnly = shared.isBoolean(options.runtimeOnly) ? options.runtimeOnly : true;
|
|
155
102
|
debug("runtimeOnly", runtimeOnly);
|
|
156
|
-
const
|
|
157
|
-
debug("jitCompilation", jitCompilation);
|
|
158
|
-
const dropMessageCompiler = jitCompilation ? !!options.dropMessageCompiler : false;
|
|
103
|
+
const dropMessageCompiler = !!options.dropMessageCompiler;
|
|
159
104
|
debug("dropMessageCompiler", dropMessageCompiler);
|
|
160
105
|
const compositionOnly = installedPkg === "vue-i18n" ? shared.isBoolean(options.compositionOnly) ? options.compositionOnly : true : true;
|
|
161
106
|
debug("compositionOnly", compositionOnly);
|
|
@@ -168,13 +113,10 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
168
113
|
warn(`'useVueI18nImportName' option is experimental`);
|
|
169
114
|
}
|
|
170
115
|
debug("useVueI18nImportName", useVueI18nImportName);
|
|
171
|
-
const getVueI18nAliasName = () =>
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
return vueI18nVersion === "8" ? `${aliasName}/dist/${aliasName}.esm.js` : `${aliasName}/dist/${installedPkg}${runtimeOnly2 ? ".runtime" : ""}.${!ssr ? "esm-bundler.js" : "node.mjs"}`;
|
|
116
|
+
const getVueI18nAliasName = () => installedPkg === "petite-vue-i18n" && shared.isBoolean(useVueI18nImportName) && useVueI18nImportName ? "vue-i18n" : installedPkg;
|
|
117
|
+
const getVueI18nAliasPath = ({ ssr = false, runtimeOnly: runtimeOnly2 = false }) => {
|
|
118
|
+
return `${installedPkg}/dist/${installedPkg}${runtimeOnly2 ? ".runtime" : ""}.${!ssr ? "esm-bundler.js" : "node.mjs"}`;
|
|
175
119
|
};
|
|
176
|
-
const esm = shared.isBoolean(options.esm) ? options.esm : true;
|
|
177
|
-
debug("esm", esm);
|
|
178
120
|
const allowDynamic = !!options.allowDynamic;
|
|
179
121
|
debug("allowDynamic", allowDynamic);
|
|
180
122
|
const strictMessage = shared.isBoolean(options.strictMessage) ? options.strictMessage : true;
|
|
@@ -206,40 +148,23 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
206
148
|
if (shared.isArray(config.resolve.alias)) {
|
|
207
149
|
config.resolve.alias.push({
|
|
208
150
|
find: vueI18nAliasName,
|
|
209
|
-
replacement: getVueI18nAliasPath(
|
|
151
|
+
replacement: getVueI18nAliasPath({
|
|
210
152
|
ssr: ssrBuild,
|
|
211
153
|
runtimeOnly
|
|
212
154
|
})
|
|
213
155
|
});
|
|
214
|
-
if (installedVueI18nBridge) {
|
|
215
|
-
config.resolve.alias.push({
|
|
216
|
-
find: "vue-i18n-bridge",
|
|
217
|
-
replacement: getVueI18nBridgeAliasPath()
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
156
|
} else if (shared.isObject(config.resolve.alias)) {
|
|
221
|
-
config.resolve.alias[vueI18nAliasName] = getVueI18nAliasPath(
|
|
157
|
+
config.resolve.alias[vueI18nAliasName] = getVueI18nAliasPath({
|
|
222
158
|
ssr: ssrBuild,
|
|
223
159
|
runtimeOnly
|
|
224
160
|
});
|
|
225
|
-
if (installedVueI18nBridge) {
|
|
226
|
-
config.resolve.alias["vue-i18n-bridge"] = getVueI18nBridgeAliasPath();
|
|
227
|
-
}
|
|
228
161
|
}
|
|
229
162
|
debug(
|
|
230
|
-
`set ${vueI18nAliasName} runtime only: ${getVueI18nAliasPath(
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
runtimeOnly
|
|
235
|
-
}
|
|
236
|
-
)}`
|
|
163
|
+
`set ${vueI18nAliasName} runtime only: ${getVueI18nAliasPath({
|
|
164
|
+
ssr: ssrBuild,
|
|
165
|
+
runtimeOnly
|
|
166
|
+
})}`
|
|
237
167
|
);
|
|
238
|
-
if (installedVueI18nBridge) {
|
|
239
|
-
debug(
|
|
240
|
-
`set vue-i18n-bridge runtime only: ${getVueI18nBridgeAliasPath()}`
|
|
241
|
-
);
|
|
242
|
-
}
|
|
243
168
|
} else if (command === "serve" && installedPkg === "petite-vue-i18n" && useVueI18nImportName) {
|
|
244
169
|
config.resolve = normalizeConfigResolveAlias(
|
|
245
170
|
config.resolve,
|
|
@@ -264,10 +189,6 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
264
189
|
debug(
|
|
265
190
|
`set __VUE_I18N_FULL_INSTALL__ is '${config.define["__VUE_I18N_FULL_INSTALL__"]}'`
|
|
266
191
|
);
|
|
267
|
-
config.define["__INTLIFY_JIT_COMPILATION__"] = jitCompilation;
|
|
268
|
-
debug(
|
|
269
|
-
`set __INTLIFY_JIT_COMPILATION__ is '${config.define["__INTLIFY_JIT_COMPILATION__"]}'`
|
|
270
|
-
);
|
|
271
192
|
config.define["__INTLIFY_DROP_MESSAGE_COMPILER__"] = dropMessageCompiler;
|
|
272
193
|
debug(
|
|
273
194
|
`set __INTLIFY_DROP_MESSAGE_COMPILER__ is '${config.define["__INTLIFY_DROP_MESSAGE_COMPILER__"]}'`
|
|
@@ -322,34 +243,23 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
322
243
|
{
|
|
323
244
|
inSourceMap,
|
|
324
245
|
isGlobal: globalSFCScope,
|
|
325
|
-
useClassComponent,
|
|
326
246
|
allowDynamic,
|
|
327
247
|
strictMessage,
|
|
328
248
|
escapeHtml,
|
|
329
|
-
|
|
330
|
-
legacy,
|
|
331
|
-
vueVersion,
|
|
332
|
-
jit: jitCompilation,
|
|
249
|
+
jit: true,
|
|
333
250
|
onlyLocales,
|
|
334
|
-
exportESM: esm,
|
|
335
251
|
forceStringify
|
|
336
252
|
}
|
|
337
253
|
);
|
|
338
254
|
debug("parseOptions", parseOptions);
|
|
339
|
-
const { code: generatedCode, map } = generate(
|
|
340
|
-
_code,
|
|
341
|
-
parseOptions,
|
|
342
|
-
bridge ? createBridgeCodeGenerator(_code, query) : void 0
|
|
343
|
-
);
|
|
255
|
+
const { code: generatedCode, map } = generate(_code, parseOptions);
|
|
344
256
|
debug("generated code", generatedCode);
|
|
345
257
|
debug("sourcemap", map, sourceMap);
|
|
346
258
|
if (_code === generatedCode)
|
|
347
259
|
return;
|
|
348
260
|
return {
|
|
349
261
|
code: generatedCode,
|
|
350
|
-
|
|
351
|
-
map: jitCompilation ? { mappings: "" } : sourceMap ? map : { mappings: "" }
|
|
352
|
-
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
262
|
+
map: { mappings: "" }
|
|
353
263
|
};
|
|
354
264
|
} else {
|
|
355
265
|
return result;
|
|
@@ -378,24 +288,16 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
378
288
|
meta.framework
|
|
379
289
|
);
|
|
380
290
|
if (isProduction) {
|
|
381
|
-
compiler.options.resolve.alias[vueI18nAliasName] = getVueI18nAliasPath(
|
|
291
|
+
compiler.options.resolve.alias[vueI18nAliasName] = getVueI18nAliasPath({
|
|
382
292
|
ssr: ssrBuild,
|
|
383
293
|
runtimeOnly
|
|
384
294
|
});
|
|
385
|
-
if (installedVueI18nBridge) {
|
|
386
|
-
compiler.options.resolve.alias["vue-i18n-bridge"] = getVueI18nBridgeAliasPath();
|
|
387
|
-
}
|
|
388
295
|
debug(
|
|
389
|
-
`set ${vueI18nAliasName}: ${getVueI18nAliasPath(
|
|
296
|
+
`set ${vueI18nAliasName}: ${getVueI18nAliasPath({
|
|
390
297
|
ssr: ssrBuild,
|
|
391
298
|
runtimeOnly
|
|
392
299
|
})}`
|
|
393
300
|
);
|
|
394
|
-
if (installedVueI18nBridge) {
|
|
395
|
-
debug(
|
|
396
|
-
`set vue-i18n-bridge runtime only: ${getVueI18nBridgeAliasPath()}`
|
|
397
|
-
);
|
|
398
|
-
}
|
|
399
301
|
} else if (!isProduction && installedPkg === "petite-vue-i18n" && useVueI18nImportName) {
|
|
400
302
|
compiler.options.resolve.alias[vueI18nAliasName] = `petite-vue-i18n/dist/petite-vue-i18n.esm-bundler.js`;
|
|
401
303
|
debug(`petite-vue-i18n alias name: ${vueI18nAliasName}`);
|
|
@@ -450,11 +352,8 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
450
352
|
isProduction,
|
|
451
353
|
{
|
|
452
354
|
forceStringify,
|
|
453
|
-
bridge,
|
|
454
355
|
strictMessage,
|
|
455
|
-
escapeHtml
|
|
456
|
-
exportESM: esm,
|
|
457
|
-
useClassComponent
|
|
356
|
+
escapeHtml
|
|
458
357
|
}
|
|
459
358
|
);
|
|
460
359
|
return {
|
|
@@ -489,23 +388,16 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
489
388
|
{
|
|
490
389
|
inSourceMap,
|
|
491
390
|
isGlobal: globalSFCScope,
|
|
492
|
-
useClassComponent,
|
|
493
391
|
allowDynamic,
|
|
494
392
|
strictMessage,
|
|
495
393
|
escapeHtml,
|
|
496
|
-
|
|
497
|
-
jit: jitCompilation,
|
|
394
|
+
jit: true,
|
|
498
395
|
onlyLocales,
|
|
499
|
-
exportESM: esm,
|
|
500
396
|
forceStringify
|
|
501
397
|
}
|
|
502
398
|
);
|
|
503
399
|
debug("parseOptions", parseOptions);
|
|
504
|
-
const { code: generatedCode, map } = generate(
|
|
505
|
-
code,
|
|
506
|
-
parseOptions,
|
|
507
|
-
bridge ? createBridgeCodeGenerator(code, query) : void 0
|
|
508
|
-
);
|
|
400
|
+
const { code: generatedCode, map } = generate(code, parseOptions);
|
|
509
401
|
debug("generated code", generatedCode);
|
|
510
402
|
debug("sourcemap", map, sourceMap);
|
|
511
403
|
if (code === generatedCode)
|
|
@@ -513,8 +405,7 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
513
405
|
return {
|
|
514
406
|
code: generatedCode,
|
|
515
407
|
// prettier-ignore
|
|
516
|
-
map:
|
|
517
|
-
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
408
|
+
map: { mappings: "" }
|
|
518
409
|
};
|
|
519
410
|
}
|
|
520
411
|
} else {
|
|
@@ -534,15 +425,10 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
534
425
|
{
|
|
535
426
|
inSourceMap,
|
|
536
427
|
isGlobal: globalSFCScope,
|
|
537
|
-
|
|
538
|
-
bridge,
|
|
539
|
-
legacy,
|
|
540
|
-
vueVersion,
|
|
541
|
-
jit: jitCompilation,
|
|
428
|
+
jit: true,
|
|
542
429
|
strictMessage,
|
|
543
430
|
escapeHtml,
|
|
544
431
|
onlyLocales,
|
|
545
|
-
exportESM: esm,
|
|
546
432
|
forceStringify
|
|
547
433
|
}
|
|
548
434
|
);
|
|
@@ -554,11 +440,7 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
554
440
|
query,
|
|
555
441
|
meta.framework
|
|
556
442
|
);
|
|
557
|
-
const { code: generatedCode, map } = generate(
|
|
558
|
-
source,
|
|
559
|
-
parseOptions,
|
|
560
|
-
bridge ? createBridgeCodeGenerator(source, query) : void 0
|
|
561
|
-
);
|
|
443
|
+
const { code: generatedCode, map } = generate(source, parseOptions);
|
|
562
444
|
debug("generated code", generatedCode);
|
|
563
445
|
debug("sourcemap", map, sourceMap);
|
|
564
446
|
if (code === generatedCode)
|
|
@@ -566,8 +448,7 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
566
448
|
return {
|
|
567
449
|
code: generatedCode,
|
|
568
450
|
// prettier-ignore
|
|
569
|
-
map:
|
|
570
|
-
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
451
|
+
map: { mappings: "" }
|
|
571
452
|
};
|
|
572
453
|
}
|
|
573
454
|
}
|
|
@@ -609,13 +490,10 @@ async function loadWebpack() {
|
|
|
609
490
|
async function generateBundleResources(resources, query, isProduction, {
|
|
610
491
|
forceStringify = false,
|
|
611
492
|
isGlobal = false,
|
|
612
|
-
bridge = false,
|
|
613
493
|
onlyLocales = [],
|
|
614
|
-
exportESM = true,
|
|
615
494
|
strictMessage = true,
|
|
616
495
|
escapeHtml = false,
|
|
617
|
-
|
|
618
|
-
jit = false
|
|
496
|
+
jit = true
|
|
619
497
|
}) {
|
|
620
498
|
const codes = [];
|
|
621
499
|
for (const res of resources) {
|
|
@@ -626,21 +504,14 @@ async function generateBundleResources(resources, query, isProduction, {
|
|
|
626
504
|
const generate = /json5?/.test(ext) ? bundleUtils.generateJSON : bundleUtils.generateYAML;
|
|
627
505
|
const parseOptions = getOptions(res, isProduction, {}, false, {
|
|
628
506
|
isGlobal,
|
|
629
|
-
useClassComponent,
|
|
630
|
-
bridge,
|
|
631
507
|
jit,
|
|
632
508
|
onlyLocales,
|
|
633
|
-
exportESM,
|
|
634
509
|
strictMessage,
|
|
635
510
|
escapeHtml,
|
|
636
511
|
forceStringify
|
|
637
512
|
});
|
|
638
513
|
parseOptions.type = "bare";
|
|
639
|
-
const { code } = generate(
|
|
640
|
-
source,
|
|
641
|
-
parseOptions,
|
|
642
|
-
bridge ? createBridgeCodeGenerator(source, query) : void 0
|
|
643
|
-
);
|
|
514
|
+
const { code } = generate(source, parseOptions);
|
|
644
515
|
debug("generated code", code);
|
|
645
516
|
codes.push(`${JSON.stringify(name)}: ${code}`);
|
|
646
517
|
}
|
|
@@ -705,16 +576,11 @@ function getOptions(filename, isProduction, query, sourceMap, {
|
|
|
705
576
|
inSourceMap = void 0,
|
|
706
577
|
forceStringify = false,
|
|
707
578
|
isGlobal = false,
|
|
708
|
-
bridge = false,
|
|
709
|
-
legacy = false,
|
|
710
|
-
vueVersion = "v2.6",
|
|
711
579
|
onlyLocales = [],
|
|
712
|
-
exportESM = true,
|
|
713
|
-
useClassComponent = false,
|
|
714
580
|
allowDynamic = false,
|
|
715
581
|
strictMessage = true,
|
|
716
582
|
escapeHtml = false,
|
|
717
|
-
jit =
|
|
583
|
+
jit = true
|
|
718
584
|
}) {
|
|
719
585
|
const mode = isProduction ? "production" : "development";
|
|
720
586
|
const baseOptions = {
|
|
@@ -722,16 +588,11 @@ function getOptions(filename, isProduction, query, sourceMap, {
|
|
|
722
588
|
sourceMap,
|
|
723
589
|
inSourceMap,
|
|
724
590
|
forceStringify,
|
|
725
|
-
useClassComponent,
|
|
726
591
|
allowDynamic,
|
|
727
592
|
strictMessage,
|
|
728
593
|
escapeHtml,
|
|
729
|
-
bridge,
|
|
730
|
-
legacy,
|
|
731
|
-
vueVersion,
|
|
732
594
|
jit,
|
|
733
595
|
onlyLocales,
|
|
734
|
-
exportESM,
|
|
735
596
|
env: mode,
|
|
736
597
|
onWarn: (msg) => {
|
|
737
598
|
warn(`${filename} ${msg}`);
|
package/lib/index.d.cts
CHANGED
package/lib/index.d.mts
CHANGED
package/lib/index.d.ts
CHANGED
package/lib/index.mjs
CHANGED
|
@@ -2,12 +2,10 @@ import { createUnplugin } from 'unplugin';
|
|
|
2
2
|
import { normalize, parse } from 'pathe';
|
|
3
3
|
import createDebug from 'debug';
|
|
4
4
|
import fg from 'fast-glob';
|
|
5
|
-
import {
|
|
5
|
+
import { isArray, isString, isBoolean, isObject, isNumber, isEmptyObject, assign, generateCodeFrame } from '@intlify/shared';
|
|
6
6
|
import { createFilter } from '@rollup/pluginutils';
|
|
7
|
-
import { checkInstallPackage,
|
|
7
|
+
import { checkInstallPackage, generateJSON, generateYAML, generateJavaScript } from '@intlify/bundle-utils';
|
|
8
8
|
import { parse as parse$1 } from '@vue/compiler-sfc';
|
|
9
|
-
import JSON5 from 'json5';
|
|
10
|
-
import yaml from 'js-yaml';
|
|
11
9
|
import { promises } from 'fs';
|
|
12
10
|
import pc from 'picocolors';
|
|
13
11
|
|
|
@@ -49,29 +47,6 @@ function parseVueRequest(id) {
|
|
|
49
47
|
};
|
|
50
48
|
}
|
|
51
49
|
|
|
52
|
-
function createBridgeCodeGenerator(source, query) {
|
|
53
|
-
return () => {
|
|
54
|
-
const data = convert(source, query.lang);
|
|
55
|
-
let value = JSON.parse(data);
|
|
56
|
-
if (isString(query.locale)) {
|
|
57
|
-
value = Object.assign({}, { [query.locale]: value });
|
|
58
|
-
}
|
|
59
|
-
return JSON.stringify(value).replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029").replace(/\\/g, "\\\\").replace(/\u0027/g, "\\u0027");
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
function convert(source, lang) {
|
|
63
|
-
switch (lang) {
|
|
64
|
-
case "yaml":
|
|
65
|
-
case "yml":
|
|
66
|
-
const data = yaml.load(source);
|
|
67
|
-
return JSON.stringify(data, void 0, " ");
|
|
68
|
-
case "json5":
|
|
69
|
-
return JSON.stringify(JSON5.parse(source));
|
|
70
|
-
default:
|
|
71
|
-
return source;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
50
|
function warn(...args) {
|
|
76
51
|
console.warn(pc.yellow(pc.bold(`[unplugin-vue-i18n] `)), ...args);
|
|
77
52
|
}
|
|
@@ -89,11 +64,6 @@ const INTLIFY_BUNDLE_IMPORT_ID = "@intlify/unplugin-vue-i18n/messages";
|
|
|
89
64
|
const VIRTUAL_PREFIX = "\0";
|
|
90
65
|
const debug = createDebug("unplugin-vue-i18n");
|
|
91
66
|
const installedPkg = checkInstallPackage("@intlify/unplugin-vue-i18n", debug);
|
|
92
|
-
const installedVueI18nBridge = checkVueI18nBridgeInstallPackage(debug);
|
|
93
|
-
const vueI18nVersion = getVueI18nVersion(debug);
|
|
94
|
-
if (vueI18nVersion === "8") {
|
|
95
|
-
warn(`vue-i18n@8 is not supported, since sinece Vue 2 was EOL on 2023.`);
|
|
96
|
-
}
|
|
97
67
|
const unplugin = createUnplugin((options = {}, meta) => {
|
|
98
68
|
debug("plugin options:", options, meta.framework);
|
|
99
69
|
if (!["vite", "webpack"].includes(meta.framework)) {
|
|
@@ -118,32 +88,9 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
118
88
|
const forceStringify = !!options.forceStringify;
|
|
119
89
|
const defaultSFCLang = isString(options.defaultSFCLang) ? options.defaultSFCLang : "json";
|
|
120
90
|
const globalSFCScope = !!options.globalSFCScope;
|
|
121
|
-
const useClassComponent = !!options.useClassComponent;
|
|
122
|
-
const bridge = !!options.bridge;
|
|
123
|
-
debug("bridge", bridge);
|
|
124
|
-
if (bridge) {
|
|
125
|
-
warn(
|
|
126
|
-
`'bridge' option is deprecated, since Vue 2 was EOL on 2023. that option will be removed in 4.0.`
|
|
127
|
-
);
|
|
128
|
-
}
|
|
129
|
-
const legacy = !!options.legacy;
|
|
130
|
-
debug("legacy", legacy);
|
|
131
|
-
if (legacy) {
|
|
132
|
-
warn(
|
|
133
|
-
`'legacy' option is deprecated, since Vue 2 was EOL on 2023. that option will be removed in 4.0.`
|
|
134
|
-
);
|
|
135
|
-
}
|
|
136
|
-
const vueVersion = isString(options.vueVersion) ? options.vueVersion : void 0;
|
|
137
|
-
if (vueVersion) {
|
|
138
|
-
warn(
|
|
139
|
-
`'vueVersion' option is deprecated, since Vue 2 was EOL on 2023. that option will be removed in 4.0.`
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
91
|
const runtimeOnly = isBoolean(options.runtimeOnly) ? options.runtimeOnly : true;
|
|
143
92
|
debug("runtimeOnly", runtimeOnly);
|
|
144
|
-
const
|
|
145
|
-
debug("jitCompilation", jitCompilation);
|
|
146
|
-
const dropMessageCompiler = jitCompilation ? !!options.dropMessageCompiler : false;
|
|
93
|
+
const dropMessageCompiler = !!options.dropMessageCompiler;
|
|
147
94
|
debug("dropMessageCompiler", dropMessageCompiler);
|
|
148
95
|
const compositionOnly = installedPkg === "vue-i18n" ? isBoolean(options.compositionOnly) ? options.compositionOnly : true : true;
|
|
149
96
|
debug("compositionOnly", compositionOnly);
|
|
@@ -156,13 +103,10 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
156
103
|
warn(`'useVueI18nImportName' option is experimental`);
|
|
157
104
|
}
|
|
158
105
|
debug("useVueI18nImportName", useVueI18nImportName);
|
|
159
|
-
const getVueI18nAliasName = () =>
|
|
160
|
-
const
|
|
161
|
-
|
|
162
|
-
return vueI18nVersion === "8" ? `${aliasName}/dist/${aliasName}.esm.js` : `${aliasName}/dist/${installedPkg}${runtimeOnly2 ? ".runtime" : ""}.${!ssr ? "esm-bundler.js" : "node.mjs"}`;
|
|
106
|
+
const getVueI18nAliasName = () => installedPkg === "petite-vue-i18n" && isBoolean(useVueI18nImportName) && useVueI18nImportName ? "vue-i18n" : installedPkg;
|
|
107
|
+
const getVueI18nAliasPath = ({ ssr = false, runtimeOnly: runtimeOnly2 = false }) => {
|
|
108
|
+
return `${installedPkg}/dist/${installedPkg}${runtimeOnly2 ? ".runtime" : ""}.${!ssr ? "esm-bundler.js" : "node.mjs"}`;
|
|
163
109
|
};
|
|
164
|
-
const esm = isBoolean(options.esm) ? options.esm : true;
|
|
165
|
-
debug("esm", esm);
|
|
166
110
|
const allowDynamic = !!options.allowDynamic;
|
|
167
111
|
debug("allowDynamic", allowDynamic);
|
|
168
112
|
const strictMessage = isBoolean(options.strictMessage) ? options.strictMessage : true;
|
|
@@ -194,40 +138,23 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
194
138
|
if (isArray(config.resolve.alias)) {
|
|
195
139
|
config.resolve.alias.push({
|
|
196
140
|
find: vueI18nAliasName,
|
|
197
|
-
replacement: getVueI18nAliasPath(
|
|
141
|
+
replacement: getVueI18nAliasPath({
|
|
198
142
|
ssr: ssrBuild,
|
|
199
143
|
runtimeOnly
|
|
200
144
|
})
|
|
201
145
|
});
|
|
202
|
-
if (installedVueI18nBridge) {
|
|
203
|
-
config.resolve.alias.push({
|
|
204
|
-
find: "vue-i18n-bridge",
|
|
205
|
-
replacement: getVueI18nBridgeAliasPath()
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
146
|
} else if (isObject(config.resolve.alias)) {
|
|
209
|
-
config.resolve.alias[vueI18nAliasName] = getVueI18nAliasPath(
|
|
147
|
+
config.resolve.alias[vueI18nAliasName] = getVueI18nAliasPath({
|
|
210
148
|
ssr: ssrBuild,
|
|
211
149
|
runtimeOnly
|
|
212
150
|
});
|
|
213
|
-
if (installedVueI18nBridge) {
|
|
214
|
-
config.resolve.alias["vue-i18n-bridge"] = getVueI18nBridgeAliasPath();
|
|
215
|
-
}
|
|
216
151
|
}
|
|
217
152
|
debug(
|
|
218
|
-
`set ${vueI18nAliasName} runtime only: ${getVueI18nAliasPath(
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
runtimeOnly
|
|
223
|
-
}
|
|
224
|
-
)}`
|
|
153
|
+
`set ${vueI18nAliasName} runtime only: ${getVueI18nAliasPath({
|
|
154
|
+
ssr: ssrBuild,
|
|
155
|
+
runtimeOnly
|
|
156
|
+
})}`
|
|
225
157
|
);
|
|
226
|
-
if (installedVueI18nBridge) {
|
|
227
|
-
debug(
|
|
228
|
-
`set vue-i18n-bridge runtime only: ${getVueI18nBridgeAliasPath()}`
|
|
229
|
-
);
|
|
230
|
-
}
|
|
231
158
|
} else if (command === "serve" && installedPkg === "petite-vue-i18n" && useVueI18nImportName) {
|
|
232
159
|
config.resolve = normalizeConfigResolveAlias(
|
|
233
160
|
config.resolve,
|
|
@@ -252,10 +179,6 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
252
179
|
debug(
|
|
253
180
|
`set __VUE_I18N_FULL_INSTALL__ is '${config.define["__VUE_I18N_FULL_INSTALL__"]}'`
|
|
254
181
|
);
|
|
255
|
-
config.define["__INTLIFY_JIT_COMPILATION__"] = jitCompilation;
|
|
256
|
-
debug(
|
|
257
|
-
`set __INTLIFY_JIT_COMPILATION__ is '${config.define["__INTLIFY_JIT_COMPILATION__"]}'`
|
|
258
|
-
);
|
|
259
182
|
config.define["__INTLIFY_DROP_MESSAGE_COMPILER__"] = dropMessageCompiler;
|
|
260
183
|
debug(
|
|
261
184
|
`set __INTLIFY_DROP_MESSAGE_COMPILER__ is '${config.define["__INTLIFY_DROP_MESSAGE_COMPILER__"]}'`
|
|
@@ -310,34 +233,23 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
310
233
|
{
|
|
311
234
|
inSourceMap,
|
|
312
235
|
isGlobal: globalSFCScope,
|
|
313
|
-
useClassComponent,
|
|
314
236
|
allowDynamic,
|
|
315
237
|
strictMessage,
|
|
316
238
|
escapeHtml,
|
|
317
|
-
|
|
318
|
-
legacy,
|
|
319
|
-
vueVersion,
|
|
320
|
-
jit: jitCompilation,
|
|
239
|
+
jit: true,
|
|
321
240
|
onlyLocales,
|
|
322
|
-
exportESM: esm,
|
|
323
241
|
forceStringify
|
|
324
242
|
}
|
|
325
243
|
);
|
|
326
244
|
debug("parseOptions", parseOptions);
|
|
327
|
-
const { code: generatedCode, map } = generate(
|
|
328
|
-
_code,
|
|
329
|
-
parseOptions,
|
|
330
|
-
bridge ? createBridgeCodeGenerator(_code, query) : void 0
|
|
331
|
-
);
|
|
245
|
+
const { code: generatedCode, map } = generate(_code, parseOptions);
|
|
332
246
|
debug("generated code", generatedCode);
|
|
333
247
|
debug("sourcemap", map, sourceMap);
|
|
334
248
|
if (_code === generatedCode)
|
|
335
249
|
return;
|
|
336
250
|
return {
|
|
337
251
|
code: generatedCode,
|
|
338
|
-
|
|
339
|
-
map: jitCompilation ? { mappings: "" } : sourceMap ? map : { mappings: "" }
|
|
340
|
-
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
252
|
+
map: { mappings: "" }
|
|
341
253
|
};
|
|
342
254
|
} else {
|
|
343
255
|
return result;
|
|
@@ -366,24 +278,16 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
366
278
|
meta.framework
|
|
367
279
|
);
|
|
368
280
|
if (isProduction) {
|
|
369
|
-
compiler.options.resolve.alias[vueI18nAliasName] = getVueI18nAliasPath(
|
|
281
|
+
compiler.options.resolve.alias[vueI18nAliasName] = getVueI18nAliasPath({
|
|
370
282
|
ssr: ssrBuild,
|
|
371
283
|
runtimeOnly
|
|
372
284
|
});
|
|
373
|
-
if (installedVueI18nBridge) {
|
|
374
|
-
compiler.options.resolve.alias["vue-i18n-bridge"] = getVueI18nBridgeAliasPath();
|
|
375
|
-
}
|
|
376
285
|
debug(
|
|
377
|
-
`set ${vueI18nAliasName}: ${getVueI18nAliasPath(
|
|
286
|
+
`set ${vueI18nAliasName}: ${getVueI18nAliasPath({
|
|
378
287
|
ssr: ssrBuild,
|
|
379
288
|
runtimeOnly
|
|
380
289
|
})}`
|
|
381
290
|
);
|
|
382
|
-
if (installedVueI18nBridge) {
|
|
383
|
-
debug(
|
|
384
|
-
`set vue-i18n-bridge runtime only: ${getVueI18nBridgeAliasPath()}`
|
|
385
|
-
);
|
|
386
|
-
}
|
|
387
291
|
} else if (!isProduction && installedPkg === "petite-vue-i18n" && useVueI18nImportName) {
|
|
388
292
|
compiler.options.resolve.alias[vueI18nAliasName] = `petite-vue-i18n/dist/petite-vue-i18n.esm-bundler.js`;
|
|
389
293
|
debug(`petite-vue-i18n alias name: ${vueI18nAliasName}`);
|
|
@@ -438,11 +342,8 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
438
342
|
isProduction,
|
|
439
343
|
{
|
|
440
344
|
forceStringify,
|
|
441
|
-
bridge,
|
|
442
345
|
strictMessage,
|
|
443
|
-
escapeHtml
|
|
444
|
-
exportESM: esm,
|
|
445
|
-
useClassComponent
|
|
346
|
+
escapeHtml
|
|
446
347
|
}
|
|
447
348
|
);
|
|
448
349
|
return {
|
|
@@ -477,23 +378,16 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
477
378
|
{
|
|
478
379
|
inSourceMap,
|
|
479
380
|
isGlobal: globalSFCScope,
|
|
480
|
-
useClassComponent,
|
|
481
381
|
allowDynamic,
|
|
482
382
|
strictMessage,
|
|
483
383
|
escapeHtml,
|
|
484
|
-
|
|
485
|
-
jit: jitCompilation,
|
|
384
|
+
jit: true,
|
|
486
385
|
onlyLocales,
|
|
487
|
-
exportESM: esm,
|
|
488
386
|
forceStringify
|
|
489
387
|
}
|
|
490
388
|
);
|
|
491
389
|
debug("parseOptions", parseOptions);
|
|
492
|
-
const { code: generatedCode, map } = generate(
|
|
493
|
-
code,
|
|
494
|
-
parseOptions,
|
|
495
|
-
bridge ? createBridgeCodeGenerator(code, query) : void 0
|
|
496
|
-
);
|
|
390
|
+
const { code: generatedCode, map } = generate(code, parseOptions);
|
|
497
391
|
debug("generated code", generatedCode);
|
|
498
392
|
debug("sourcemap", map, sourceMap);
|
|
499
393
|
if (code === generatedCode)
|
|
@@ -501,8 +395,7 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
501
395
|
return {
|
|
502
396
|
code: generatedCode,
|
|
503
397
|
// prettier-ignore
|
|
504
|
-
map:
|
|
505
|
-
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
398
|
+
map: { mappings: "" }
|
|
506
399
|
};
|
|
507
400
|
}
|
|
508
401
|
} else {
|
|
@@ -522,15 +415,10 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
522
415
|
{
|
|
523
416
|
inSourceMap,
|
|
524
417
|
isGlobal: globalSFCScope,
|
|
525
|
-
|
|
526
|
-
bridge,
|
|
527
|
-
legacy,
|
|
528
|
-
vueVersion,
|
|
529
|
-
jit: jitCompilation,
|
|
418
|
+
jit: true,
|
|
530
419
|
strictMessage,
|
|
531
420
|
escapeHtml,
|
|
532
421
|
onlyLocales,
|
|
533
|
-
exportESM: esm,
|
|
534
422
|
forceStringify
|
|
535
423
|
}
|
|
536
424
|
);
|
|
@@ -542,11 +430,7 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
542
430
|
query,
|
|
543
431
|
meta.framework
|
|
544
432
|
);
|
|
545
|
-
const { code: generatedCode, map } = generate(
|
|
546
|
-
source,
|
|
547
|
-
parseOptions,
|
|
548
|
-
bridge ? createBridgeCodeGenerator(source, query) : void 0
|
|
549
|
-
);
|
|
433
|
+
const { code: generatedCode, map } = generate(source, parseOptions);
|
|
550
434
|
debug("generated code", generatedCode);
|
|
551
435
|
debug("sourcemap", map, sourceMap);
|
|
552
436
|
if (code === generatedCode)
|
|
@@ -554,8 +438,7 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
554
438
|
return {
|
|
555
439
|
code: generatedCode,
|
|
556
440
|
// prettier-ignore
|
|
557
|
-
map:
|
|
558
|
-
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
441
|
+
map: { mappings: "" }
|
|
559
442
|
};
|
|
560
443
|
}
|
|
561
444
|
}
|
|
@@ -597,13 +480,10 @@ async function loadWebpack() {
|
|
|
597
480
|
async function generateBundleResources(resources, query, isProduction, {
|
|
598
481
|
forceStringify = false,
|
|
599
482
|
isGlobal = false,
|
|
600
|
-
bridge = false,
|
|
601
483
|
onlyLocales = [],
|
|
602
|
-
exportESM = true,
|
|
603
484
|
strictMessage = true,
|
|
604
485
|
escapeHtml = false,
|
|
605
|
-
|
|
606
|
-
jit = false
|
|
486
|
+
jit = true
|
|
607
487
|
}) {
|
|
608
488
|
const codes = [];
|
|
609
489
|
for (const res of resources) {
|
|
@@ -614,21 +494,14 @@ async function generateBundleResources(resources, query, isProduction, {
|
|
|
614
494
|
const generate = /json5?/.test(ext) ? generateJSON : generateYAML;
|
|
615
495
|
const parseOptions = getOptions(res, isProduction, {}, false, {
|
|
616
496
|
isGlobal,
|
|
617
|
-
useClassComponent,
|
|
618
|
-
bridge,
|
|
619
497
|
jit,
|
|
620
498
|
onlyLocales,
|
|
621
|
-
exportESM,
|
|
622
499
|
strictMessage,
|
|
623
500
|
escapeHtml,
|
|
624
501
|
forceStringify
|
|
625
502
|
});
|
|
626
503
|
parseOptions.type = "bare";
|
|
627
|
-
const { code } = generate(
|
|
628
|
-
source,
|
|
629
|
-
parseOptions,
|
|
630
|
-
bridge ? createBridgeCodeGenerator(source, query) : void 0
|
|
631
|
-
);
|
|
504
|
+
const { code } = generate(source, parseOptions);
|
|
632
505
|
debug("generated code", code);
|
|
633
506
|
codes.push(`${JSON.stringify(name)}: ${code}`);
|
|
634
507
|
}
|
|
@@ -693,16 +566,11 @@ function getOptions(filename, isProduction, query, sourceMap, {
|
|
|
693
566
|
inSourceMap = void 0,
|
|
694
567
|
forceStringify = false,
|
|
695
568
|
isGlobal = false,
|
|
696
|
-
bridge = false,
|
|
697
|
-
legacy = false,
|
|
698
|
-
vueVersion = "v2.6",
|
|
699
569
|
onlyLocales = [],
|
|
700
|
-
exportESM = true,
|
|
701
|
-
useClassComponent = false,
|
|
702
570
|
allowDynamic = false,
|
|
703
571
|
strictMessage = true,
|
|
704
572
|
escapeHtml = false,
|
|
705
|
-
jit =
|
|
573
|
+
jit = true
|
|
706
574
|
}) {
|
|
707
575
|
const mode = isProduction ? "production" : "development";
|
|
708
576
|
const baseOptions = {
|
|
@@ -710,16 +578,11 @@ function getOptions(filename, isProduction, query, sourceMap, {
|
|
|
710
578
|
sourceMap,
|
|
711
579
|
inSourceMap,
|
|
712
580
|
forceStringify,
|
|
713
|
-
useClassComponent,
|
|
714
581
|
allowDynamic,
|
|
715
582
|
strictMessage,
|
|
716
583
|
escapeHtml,
|
|
717
|
-
bridge,
|
|
718
|
-
legacy,
|
|
719
|
-
vueVersion,
|
|
720
584
|
jit,
|
|
721
585
|
onlyLocales,
|
|
722
|
-
exportESM,
|
|
723
586
|
env: mode,
|
|
724
587
|
onWarn: (msg) => {
|
|
725
588
|
warn(`${filename} ${msg}`);
|
package/lib/types.d.cts
CHANGED
|
@@ -1,24 +1,16 @@
|
|
|
1
|
-
import { CodeGenOptions } from '@intlify/bundle-utils';
|
|
2
|
-
|
|
3
1
|
type SFCLangFormat = 'json' | 'json5' | 'yml' | 'yaml';
|
|
4
2
|
interface PluginOptions {
|
|
5
3
|
include?: string | string[];
|
|
6
4
|
onlyLocales?: string | string[];
|
|
7
5
|
allowDynamic?: boolean;
|
|
8
|
-
jitCompilation?: boolean;
|
|
9
6
|
dropMessageCompiler?: boolean;
|
|
10
7
|
runtimeOnly?: boolean;
|
|
11
8
|
compositionOnly?: boolean;
|
|
12
9
|
ssr?: boolean;
|
|
13
10
|
fullInstall?: boolean;
|
|
14
|
-
esm?: boolean;
|
|
15
11
|
forceStringify?: boolean;
|
|
16
12
|
defaultSFCLang?: SFCLangFormat;
|
|
17
13
|
globalSFCScope?: boolean;
|
|
18
|
-
bridge?: boolean;
|
|
19
|
-
legacy?: boolean;
|
|
20
|
-
vueVersion?: CodeGenOptions['vueVersion'];
|
|
21
|
-
useClassComponent?: boolean;
|
|
22
14
|
useVueI18nImportName?: boolean;
|
|
23
15
|
strictMessage?: boolean;
|
|
24
16
|
escapeHtml?: boolean;
|
package/lib/types.d.mts
CHANGED
|
@@ -1,24 +1,16 @@
|
|
|
1
|
-
import { CodeGenOptions } from '@intlify/bundle-utils';
|
|
2
|
-
|
|
3
1
|
type SFCLangFormat = 'json' | 'json5' | 'yml' | 'yaml';
|
|
4
2
|
interface PluginOptions {
|
|
5
3
|
include?: string | string[];
|
|
6
4
|
onlyLocales?: string | string[];
|
|
7
5
|
allowDynamic?: boolean;
|
|
8
|
-
jitCompilation?: boolean;
|
|
9
6
|
dropMessageCompiler?: boolean;
|
|
10
7
|
runtimeOnly?: boolean;
|
|
11
8
|
compositionOnly?: boolean;
|
|
12
9
|
ssr?: boolean;
|
|
13
10
|
fullInstall?: boolean;
|
|
14
|
-
esm?: boolean;
|
|
15
11
|
forceStringify?: boolean;
|
|
16
12
|
defaultSFCLang?: SFCLangFormat;
|
|
17
13
|
globalSFCScope?: boolean;
|
|
18
|
-
bridge?: boolean;
|
|
19
|
-
legacy?: boolean;
|
|
20
|
-
vueVersion?: CodeGenOptions['vueVersion'];
|
|
21
|
-
useClassComponent?: boolean;
|
|
22
14
|
useVueI18nImportName?: boolean;
|
|
23
15
|
strictMessage?: boolean;
|
|
24
16
|
escapeHtml?: boolean;
|
package/lib/types.d.ts
CHANGED
|
@@ -1,24 +1,16 @@
|
|
|
1
|
-
import { CodeGenOptions } from '@intlify/bundle-utils';
|
|
2
|
-
|
|
3
1
|
type SFCLangFormat = 'json' | 'json5' | 'yml' | 'yaml';
|
|
4
2
|
interface PluginOptions {
|
|
5
3
|
include?: string | string[];
|
|
6
4
|
onlyLocales?: string | string[];
|
|
7
5
|
allowDynamic?: boolean;
|
|
8
|
-
jitCompilation?: boolean;
|
|
9
6
|
dropMessageCompiler?: boolean;
|
|
10
7
|
runtimeOnly?: boolean;
|
|
11
8
|
compositionOnly?: boolean;
|
|
12
9
|
ssr?: boolean;
|
|
13
10
|
fullInstall?: boolean;
|
|
14
|
-
esm?: boolean;
|
|
15
11
|
forceStringify?: boolean;
|
|
16
12
|
defaultSFCLang?: SFCLangFormat;
|
|
17
13
|
globalSFCScope?: boolean;
|
|
18
|
-
bridge?: boolean;
|
|
19
|
-
legacy?: boolean;
|
|
20
|
-
vueVersion?: CodeGenOptions['vueVersion'];
|
|
21
|
-
useClassComponent?: boolean;
|
|
22
14
|
useVueI18nImportName?: boolean;
|
|
23
15
|
strictMessage?: boolean;
|
|
24
16
|
escapeHtml?: boolean;
|
package/lib/vite.cjs
CHANGED
package/lib/vite.d.cts
CHANGED
package/lib/vite.d.mts
CHANGED
package/lib/vite.d.ts
CHANGED
package/lib/vite.mjs
CHANGED
package/lib/webpack.cjs
CHANGED
package/lib/webpack.d.cts
CHANGED
package/lib/webpack.d.mts
CHANGED
package/lib/webpack.d.ts
CHANGED
package/lib/webpack.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlify/unplugin-vue-i18n",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0-beta.0",
|
|
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": "
|
|
29
|
+
"@intlify/bundle-utils": "^9.0.0-beta.0",
|
|
30
|
+
"@intlify/shared": "next",
|
|
31
31
|
"@rollup/pluginutils": "^5.1.0",
|
|
32
32
|
"@vue/compiler-sfc": "^3.2.47",
|
|
33
33
|
"debug": "^4.3.3",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"unbuild": "^2.0.0"
|
|
44
44
|
},
|
|
45
45
|
"engines": {
|
|
46
|
-
"node": ">=
|
|
46
|
+
"node": ">= 18"
|
|
47
47
|
},
|
|
48
48
|
"files": [
|
|
49
49
|
"lib",
|