@intlify/unplugin-vue-i18n 11.2.0 → 11.2.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/lib/index.cjs +134 -25
- package/lib/index.mjs +132 -23
- package/lib/vite.cjs +1 -1
- package/lib/vite.mjs +1 -1
- package/lib/webpack.cjs +1 -1
- package/lib/webpack.mjs +1 -1
- package/package.json +4 -4
package/lib/index.cjs
CHANGED
|
@@ -10,9 +10,9 @@ const bundleUtils = require('@intlify/bundle-utils');
|
|
|
10
10
|
const pluginutils = require('@rollup/pluginutils');
|
|
11
11
|
const fg = require('fast-glob');
|
|
12
12
|
const node_fs = require('node:fs');
|
|
13
|
-
const path = require('node:path');
|
|
14
13
|
const compilerSfc = require('vue/compiler-sfc');
|
|
15
14
|
const pc = require('picocolors');
|
|
15
|
+
const path = require('node:path');
|
|
16
16
|
const eslintUitls = require('@eslint-community/eslint-utils');
|
|
17
17
|
const vueI18nExtensions = require('@intlify/vue-i18n-extensions');
|
|
18
18
|
const scopeManager = require('@typescript-eslint/scope-manager');
|
|
@@ -21,8 +21,8 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
|
|
|
21
21
|
|
|
22
22
|
const createDebug__default = /*#__PURE__*/_interopDefaultCompat(createDebug);
|
|
23
23
|
const fg__default = /*#__PURE__*/_interopDefaultCompat(fg);
|
|
24
|
-
const path__default = /*#__PURE__*/_interopDefaultCompat(path);
|
|
25
24
|
const pc__default = /*#__PURE__*/_interopDefaultCompat(pc);
|
|
25
|
+
const path__default = /*#__PURE__*/_interopDefaultCompat(path);
|
|
26
26
|
const eslintUitls__default = /*#__PURE__*/_interopDefaultCompat(eslintUitls);
|
|
27
27
|
|
|
28
28
|
function normalizeGlobOption(val) {
|
|
@@ -178,13 +178,10 @@ function getDescriptor(filename, code, options) {
|
|
|
178
178
|
|
|
179
179
|
const INTLIFY_BUNDLE_IMPORT_ID = "@intlify/unplugin-vue-i18n/messages";
|
|
180
180
|
const VIRTUAL_PREFIX = "\0";
|
|
181
|
-
const RE_INTLIFY_BUNDLE_IMPORT_ID = new RegExp(`^${INTLIFY_BUNDLE_IMPORT_ID}$`);
|
|
182
|
-
const RE_VIRTUAL_PREFIXED_INTLIFY_BUNDLE_IMPORT_ID = new RegExp(
|
|
183
|
-
`^${VIRTUAL_PREFIX}${INTLIFY_BUNDLE_IMPORT_ID}$`
|
|
184
|
-
);
|
|
185
181
|
const RE_RESOURCE_FORMAT = /\.(json5?|ya?ml|[c|m]?[j|t]s)$/;
|
|
186
182
|
const RE_SFC_I18N_CUSTOM_BLOCK = /\?vue&type=i18n/;
|
|
187
183
|
const RE_SFC_I18N_WEBPACK_CUSTOM_BLOCK = /blockType=i18n/;
|
|
184
|
+
const VITE_VIRTUAL_PREFIX = "\0intlify-i18n-";
|
|
188
185
|
const debug$3 = createDebug__default(resolveNamespace("resource"));
|
|
189
186
|
function resourcePlugin({
|
|
190
187
|
onlyLocales,
|
|
@@ -241,6 +238,21 @@ function resourcePlugin({
|
|
|
241
238
|
const getSfcParser = () => {
|
|
242
239
|
return vuePlugin ? getVueCompiler(vuePlugin).parse : compilerSfc.parse;
|
|
243
240
|
};
|
|
241
|
+
const virtualIdToRealPath = /* @__PURE__ */ new Map();
|
|
242
|
+
const realPathToVirtualId = /* @__PURE__ */ new Map();
|
|
243
|
+
let virtualCounter = 0;
|
|
244
|
+
function intlifyVirtualize(realPath) {
|
|
245
|
+
let virtualId = realPathToVirtualId.get(realPath);
|
|
246
|
+
if (!virtualId) {
|
|
247
|
+
virtualId = `${VITE_VIRTUAL_PREFIX}${virtualCounter++}`;
|
|
248
|
+
virtualIdToRealPath.set(virtualId, realPath);
|
|
249
|
+
realPathToVirtualId.set(realPath, virtualId);
|
|
250
|
+
}
|
|
251
|
+
return virtualId;
|
|
252
|
+
}
|
|
253
|
+
function isIntlifyVirtualId(id) {
|
|
254
|
+
return virtualIdToRealPath.has(id);
|
|
255
|
+
}
|
|
244
256
|
return {
|
|
245
257
|
name: resolveNamespace("resource"),
|
|
246
258
|
/**
|
|
@@ -361,17 +373,33 @@ function resourcePlugin({
|
|
|
361
373
|
}
|
|
362
374
|
},
|
|
363
375
|
resolveId: {
|
|
364
|
-
|
|
365
|
-
id
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
376
|
+
async handler(id, importer) {
|
|
377
|
+
if (id === INTLIFY_BUNDLE_IMPORT_ID) {
|
|
378
|
+
return asVirtualId(id, meta.framework);
|
|
379
|
+
}
|
|
380
|
+
if (meta.framework === "vite" && !hasViteJsonPlugin) {
|
|
381
|
+
if (id.includes("?vue&type=i18n") && /[?&]lang\.(?:json|json5)(?:$|&)/.test(id)) {
|
|
382
|
+
return intlifyVirtualize(id);
|
|
383
|
+
}
|
|
384
|
+
const idPath = id.split("?")[0];
|
|
385
|
+
if (!RE_RESOURCE_FORMAT.test(idPath)) return;
|
|
386
|
+
let resolvedPath;
|
|
387
|
+
if (idPath.startsWith(".")) {
|
|
388
|
+
const realImporter = importer && isIntlifyVirtualId(importer) ? virtualIdToRealPath.get(importer) : importer;
|
|
389
|
+
if (!realImporter) return;
|
|
390
|
+
resolvedPath = pathe.resolve(pathe.dirname(realImporter), idPath);
|
|
391
|
+
} else if (idPath.startsWith("/") || /^[a-z]:[/\\]/i.test(idPath)) {
|
|
392
|
+
resolvedPath = idPath;
|
|
393
|
+
} else {
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
const filter = await getFilter();
|
|
397
|
+
if (!filter(resolvedPath)) return;
|
|
398
|
+
return intlifyVirtualize(resolvedPath);
|
|
399
|
+
}
|
|
369
400
|
}
|
|
370
401
|
},
|
|
371
402
|
load: {
|
|
372
|
-
filter: {
|
|
373
|
-
id: RE_VIRTUAL_PREFIXED_INTLIFY_BUNDLE_IMPORT_ID
|
|
374
|
-
},
|
|
375
403
|
async handler(id) {
|
|
376
404
|
debug$3("load", id);
|
|
377
405
|
if (INTLIFY_BUNDLE_IMPORT_ID === getVirtualId(id, meta.framework) && include) {
|
|
@@ -392,10 +420,91 @@ function resourcePlugin({
|
|
|
392
420
|
map: { mappings: "" }
|
|
393
421
|
};
|
|
394
422
|
}
|
|
423
|
+
if (isIntlifyVirtualId(id)) {
|
|
424
|
+
const realId = virtualIdToRealPath.get(id);
|
|
425
|
+
if (realId.includes("?vue&type=i18n")) {
|
|
426
|
+
const { filename, query } = parseVueRequest(realId);
|
|
427
|
+
this.addWatchFile(filename);
|
|
428
|
+
const sfcSource = await node_fs.promises.readFile(filename, "utf-8");
|
|
429
|
+
const { descriptor } = getSfcParser()(sfcSource, {
|
|
430
|
+
sourceMap,
|
|
431
|
+
filename
|
|
432
|
+
});
|
|
433
|
+
const block = descriptor.customBlocks[query.index];
|
|
434
|
+
if (!block) return;
|
|
435
|
+
let source = block.src ? await node_fs.promises.readFile(block.src, "utf-8") : block.content;
|
|
436
|
+
if (typeof transformI18nBlock === "function") {
|
|
437
|
+
const modifiedSource = transformI18nBlock(source);
|
|
438
|
+
if (modifiedSource && typeof modifiedSource === "string") {
|
|
439
|
+
source = modifiedSource;
|
|
440
|
+
} else {
|
|
441
|
+
warn("transformI18nBlock should return a string");
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
let langInfo2 = defaultSFCLang;
|
|
445
|
+
if (shared.isString(query.lang)) {
|
|
446
|
+
langInfo2 = query.src ? query.lang === "i18n" ? defaultSFCLang : query.lang : query.lang;
|
|
447
|
+
}
|
|
448
|
+
if (/\.?[cm]?[jt]s$/.test(langInfo2)) {
|
|
449
|
+
source = `export default ${source.replace(/^[\s;]+/, "")}`;
|
|
450
|
+
}
|
|
451
|
+
const generate2 = getGenerator(langInfo2, bundleUtils.generateYAML);
|
|
452
|
+
const isGlobalBlock = globalSFCScope || !!query.global;
|
|
453
|
+
const parseOptions2 = getOptions(
|
|
454
|
+
filename,
|
|
455
|
+
isProduction,
|
|
456
|
+
query,
|
|
457
|
+
sourceMap,
|
|
458
|
+
{
|
|
459
|
+
isGlobal: globalSFCScope,
|
|
460
|
+
allowDynamic,
|
|
461
|
+
jit: true,
|
|
462
|
+
strictMessage,
|
|
463
|
+
escapeHtml,
|
|
464
|
+
onlyLocales,
|
|
465
|
+
forceStringify,
|
|
466
|
+
usedKeyFilter: collector && isGlobalBlock ? (keyPath) => collector.shouldKeepKey(keyPath) : void 0
|
|
467
|
+
}
|
|
468
|
+
);
|
|
469
|
+
const { code: generatedCode2 } = await generate2(source, parseOptions2);
|
|
470
|
+
return {
|
|
471
|
+
moduleType: "js",
|
|
472
|
+
code: generatedCode2,
|
|
473
|
+
map: { mappings: "" }
|
|
474
|
+
};
|
|
475
|
+
}
|
|
476
|
+
this.addWatchFile(realId);
|
|
477
|
+
const code = await node_fs.promises.readFile(realId, "utf-8");
|
|
478
|
+
const langInfo = pathe.parse(realId).ext;
|
|
479
|
+
const generate = getGenerator(langInfo);
|
|
480
|
+
const parseOptions = getOptions(
|
|
481
|
+
realId,
|
|
482
|
+
isProduction,
|
|
483
|
+
{},
|
|
484
|
+
sourceMap,
|
|
485
|
+
{
|
|
486
|
+
isGlobal: globalSFCScope,
|
|
487
|
+
allowDynamic,
|
|
488
|
+
strictMessage,
|
|
489
|
+
escapeHtml,
|
|
490
|
+
jit: true,
|
|
491
|
+
onlyLocales,
|
|
492
|
+
forceStringify,
|
|
493
|
+
usedKeyFilter: collector ? (keyPath) => collector.shouldKeepKey(keyPath) : void 0
|
|
494
|
+
}
|
|
495
|
+
);
|
|
496
|
+
const { code: generatedCode } = await generate(code, parseOptions);
|
|
497
|
+
return {
|
|
498
|
+
moduleType: "js",
|
|
499
|
+
code: generatedCode,
|
|
500
|
+
map: { mappings: "" }
|
|
501
|
+
};
|
|
502
|
+
}
|
|
395
503
|
}
|
|
396
504
|
},
|
|
397
505
|
transform: {
|
|
398
506
|
async handler(code, id) {
|
|
507
|
+
if (isIntlifyVirtualId(id)) return;
|
|
399
508
|
const filter = await getFilter();
|
|
400
509
|
if (!filter(id)) {
|
|
401
510
|
return;
|
|
@@ -405,7 +514,7 @@ function resourcePlugin({
|
|
|
405
514
|
let langInfo = defaultSFCLang;
|
|
406
515
|
let inSourceMap;
|
|
407
516
|
if (!query.vue) {
|
|
408
|
-
langInfo =
|
|
517
|
+
langInfo = pathe.parse(filename).ext;
|
|
409
518
|
const generate = getGenerator(langInfo);
|
|
410
519
|
const parseOptions = getOptions(
|
|
411
520
|
filename,
|
|
@@ -513,23 +622,23 @@ function getGenerator(ext, fallback = bundleUtils.generateJSON) {
|
|
|
513
622
|
}
|
|
514
623
|
return fallback;
|
|
515
624
|
}
|
|
516
|
-
function normalizeConfigResolveAlias(
|
|
517
|
-
if (
|
|
518
|
-
return
|
|
625
|
+
function normalizeConfigResolveAlias(resolve2, framework) {
|
|
626
|
+
if (resolve2 && resolve2.alias) {
|
|
627
|
+
return resolve2;
|
|
519
628
|
}
|
|
520
|
-
if (!
|
|
629
|
+
if (!resolve2) {
|
|
521
630
|
if (framework === "vite") {
|
|
522
631
|
return { alias: [] };
|
|
523
632
|
} else if (framework === "webpack") {
|
|
524
633
|
return { alias: {} };
|
|
525
634
|
}
|
|
526
|
-
} else if (!
|
|
635
|
+
} else if (!resolve2.alias) {
|
|
527
636
|
if (framework === "vite") {
|
|
528
|
-
|
|
529
|
-
return
|
|
637
|
+
resolve2.alias = [];
|
|
638
|
+
return resolve2;
|
|
530
639
|
} else if (framework === "webpack") {
|
|
531
|
-
|
|
532
|
-
return
|
|
640
|
+
resolve2.alias = {};
|
|
641
|
+
return resolve2;
|
|
533
642
|
}
|
|
534
643
|
}
|
|
535
644
|
}
|
|
@@ -547,7 +656,7 @@ async function generateBundleResources(resources, isProduction, {
|
|
|
547
656
|
for (const res of resources) {
|
|
548
657
|
debug$3(`${res} bundle loading ...`);
|
|
549
658
|
if (/\.(json5?|ya?ml)$/.test(res)) {
|
|
550
|
-
const { ext, name } =
|
|
659
|
+
const { ext, name } = pathe.parse(res);
|
|
551
660
|
const source = await getRaw(res);
|
|
552
661
|
const generate = /json5?/.test(ext) ? bundleUtils.generateJSON : bundleUtils.generateYAML;
|
|
553
662
|
const parseOptions = getOptions(res, isProduction, {}, false, {
|
package/lib/index.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import createDebug from 'debug';
|
|
2
2
|
import { createUnplugin } from 'unplugin';
|
|
3
3
|
import { isArray, isString, isBoolean, assign, isEmptyObject, isNumber, generateCodeFrame } from '@intlify/shared';
|
|
4
|
-
import { normalize } from 'pathe';
|
|
4
|
+
import { normalize, parse, resolve, dirname } from 'pathe';
|
|
5
5
|
import { generateJSON, generateYAML, generateJavaScript, generateTypescript } from '@intlify/bundle-utils';
|
|
6
6
|
import { createFilter } from '@rollup/pluginutils';
|
|
7
7
|
import fg from 'fast-glob';
|
|
8
8
|
import { promises } from 'node:fs';
|
|
9
|
-
import path, { parse } from 'node:path';
|
|
10
9
|
import { parse as parse$1 } from 'vue/compiler-sfc';
|
|
11
10
|
import pc from 'picocolors';
|
|
11
|
+
import path from 'node:path';
|
|
12
12
|
import eslintUitls from '@eslint-community/eslint-utils';
|
|
13
13
|
import { transformVTDirective } from '@intlify/vue-i18n-extensions';
|
|
14
14
|
import { analyze } from '@typescript-eslint/scope-manager';
|
|
@@ -166,13 +166,10 @@ function getDescriptor(filename, code, options) {
|
|
|
166
166
|
|
|
167
167
|
const INTLIFY_BUNDLE_IMPORT_ID = "@intlify/unplugin-vue-i18n/messages";
|
|
168
168
|
const VIRTUAL_PREFIX = "\0";
|
|
169
|
-
const RE_INTLIFY_BUNDLE_IMPORT_ID = new RegExp(`^${INTLIFY_BUNDLE_IMPORT_ID}$`);
|
|
170
|
-
const RE_VIRTUAL_PREFIXED_INTLIFY_BUNDLE_IMPORT_ID = new RegExp(
|
|
171
|
-
`^${VIRTUAL_PREFIX}${INTLIFY_BUNDLE_IMPORT_ID}$`
|
|
172
|
-
);
|
|
173
169
|
const RE_RESOURCE_FORMAT = /\.(json5?|ya?ml|[c|m]?[j|t]s)$/;
|
|
174
170
|
const RE_SFC_I18N_CUSTOM_BLOCK = /\?vue&type=i18n/;
|
|
175
171
|
const RE_SFC_I18N_WEBPACK_CUSTOM_BLOCK = /blockType=i18n/;
|
|
172
|
+
const VITE_VIRTUAL_PREFIX = "\0intlify-i18n-";
|
|
176
173
|
const debug$3 = createDebug(resolveNamespace("resource"));
|
|
177
174
|
function resourcePlugin({
|
|
178
175
|
onlyLocales,
|
|
@@ -229,6 +226,21 @@ function resourcePlugin({
|
|
|
229
226
|
const getSfcParser = () => {
|
|
230
227
|
return vuePlugin ? getVueCompiler(vuePlugin).parse : parse$1;
|
|
231
228
|
};
|
|
229
|
+
const virtualIdToRealPath = /* @__PURE__ */ new Map();
|
|
230
|
+
const realPathToVirtualId = /* @__PURE__ */ new Map();
|
|
231
|
+
let virtualCounter = 0;
|
|
232
|
+
function intlifyVirtualize(realPath) {
|
|
233
|
+
let virtualId = realPathToVirtualId.get(realPath);
|
|
234
|
+
if (!virtualId) {
|
|
235
|
+
virtualId = `${VITE_VIRTUAL_PREFIX}${virtualCounter++}`;
|
|
236
|
+
virtualIdToRealPath.set(virtualId, realPath);
|
|
237
|
+
realPathToVirtualId.set(realPath, virtualId);
|
|
238
|
+
}
|
|
239
|
+
return virtualId;
|
|
240
|
+
}
|
|
241
|
+
function isIntlifyVirtualId(id) {
|
|
242
|
+
return virtualIdToRealPath.has(id);
|
|
243
|
+
}
|
|
232
244
|
return {
|
|
233
245
|
name: resolveNamespace("resource"),
|
|
234
246
|
/**
|
|
@@ -349,17 +361,33 @@ function resourcePlugin({
|
|
|
349
361
|
}
|
|
350
362
|
},
|
|
351
363
|
resolveId: {
|
|
352
|
-
|
|
353
|
-
id
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
364
|
+
async handler(id, importer) {
|
|
365
|
+
if (id === INTLIFY_BUNDLE_IMPORT_ID) {
|
|
366
|
+
return asVirtualId(id, meta.framework);
|
|
367
|
+
}
|
|
368
|
+
if (meta.framework === "vite" && !hasViteJsonPlugin) {
|
|
369
|
+
if (id.includes("?vue&type=i18n") && /[?&]lang\.(?:json|json5)(?:$|&)/.test(id)) {
|
|
370
|
+
return intlifyVirtualize(id);
|
|
371
|
+
}
|
|
372
|
+
const idPath = id.split("?")[0];
|
|
373
|
+
if (!RE_RESOURCE_FORMAT.test(idPath)) return;
|
|
374
|
+
let resolvedPath;
|
|
375
|
+
if (idPath.startsWith(".")) {
|
|
376
|
+
const realImporter = importer && isIntlifyVirtualId(importer) ? virtualIdToRealPath.get(importer) : importer;
|
|
377
|
+
if (!realImporter) return;
|
|
378
|
+
resolvedPath = resolve(dirname(realImporter), idPath);
|
|
379
|
+
} else if (idPath.startsWith("/") || /^[a-z]:[/\\]/i.test(idPath)) {
|
|
380
|
+
resolvedPath = idPath;
|
|
381
|
+
} else {
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
const filter = await getFilter();
|
|
385
|
+
if (!filter(resolvedPath)) return;
|
|
386
|
+
return intlifyVirtualize(resolvedPath);
|
|
387
|
+
}
|
|
357
388
|
}
|
|
358
389
|
},
|
|
359
390
|
load: {
|
|
360
|
-
filter: {
|
|
361
|
-
id: RE_VIRTUAL_PREFIXED_INTLIFY_BUNDLE_IMPORT_ID
|
|
362
|
-
},
|
|
363
391
|
async handler(id) {
|
|
364
392
|
debug$3("load", id);
|
|
365
393
|
if (INTLIFY_BUNDLE_IMPORT_ID === getVirtualId(id, meta.framework) && include) {
|
|
@@ -380,10 +408,91 @@ function resourcePlugin({
|
|
|
380
408
|
map: { mappings: "" }
|
|
381
409
|
};
|
|
382
410
|
}
|
|
411
|
+
if (isIntlifyVirtualId(id)) {
|
|
412
|
+
const realId = virtualIdToRealPath.get(id);
|
|
413
|
+
if (realId.includes("?vue&type=i18n")) {
|
|
414
|
+
const { filename, query } = parseVueRequest(realId);
|
|
415
|
+
this.addWatchFile(filename);
|
|
416
|
+
const sfcSource = await promises.readFile(filename, "utf-8");
|
|
417
|
+
const { descriptor } = getSfcParser()(sfcSource, {
|
|
418
|
+
sourceMap,
|
|
419
|
+
filename
|
|
420
|
+
});
|
|
421
|
+
const block = descriptor.customBlocks[query.index];
|
|
422
|
+
if (!block) return;
|
|
423
|
+
let source = block.src ? await promises.readFile(block.src, "utf-8") : block.content;
|
|
424
|
+
if (typeof transformI18nBlock === "function") {
|
|
425
|
+
const modifiedSource = transformI18nBlock(source);
|
|
426
|
+
if (modifiedSource && typeof modifiedSource === "string") {
|
|
427
|
+
source = modifiedSource;
|
|
428
|
+
} else {
|
|
429
|
+
warn("transformI18nBlock should return a string");
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
let langInfo2 = defaultSFCLang;
|
|
433
|
+
if (isString(query.lang)) {
|
|
434
|
+
langInfo2 = query.src ? query.lang === "i18n" ? defaultSFCLang : query.lang : query.lang;
|
|
435
|
+
}
|
|
436
|
+
if (/\.?[cm]?[jt]s$/.test(langInfo2)) {
|
|
437
|
+
source = `export default ${source.replace(/^[\s;]+/, "")}`;
|
|
438
|
+
}
|
|
439
|
+
const generate2 = getGenerator(langInfo2, generateYAML);
|
|
440
|
+
const isGlobalBlock = globalSFCScope || !!query.global;
|
|
441
|
+
const parseOptions2 = getOptions(
|
|
442
|
+
filename,
|
|
443
|
+
isProduction,
|
|
444
|
+
query,
|
|
445
|
+
sourceMap,
|
|
446
|
+
{
|
|
447
|
+
isGlobal: globalSFCScope,
|
|
448
|
+
allowDynamic,
|
|
449
|
+
jit: true,
|
|
450
|
+
strictMessage,
|
|
451
|
+
escapeHtml,
|
|
452
|
+
onlyLocales,
|
|
453
|
+
forceStringify,
|
|
454
|
+
usedKeyFilter: collector && isGlobalBlock ? (keyPath) => collector.shouldKeepKey(keyPath) : void 0
|
|
455
|
+
}
|
|
456
|
+
);
|
|
457
|
+
const { code: generatedCode2 } = await generate2(source, parseOptions2);
|
|
458
|
+
return {
|
|
459
|
+
moduleType: "js",
|
|
460
|
+
code: generatedCode2,
|
|
461
|
+
map: { mappings: "" }
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
this.addWatchFile(realId);
|
|
465
|
+
const code = await promises.readFile(realId, "utf-8");
|
|
466
|
+
const langInfo = parse(realId).ext;
|
|
467
|
+
const generate = getGenerator(langInfo);
|
|
468
|
+
const parseOptions = getOptions(
|
|
469
|
+
realId,
|
|
470
|
+
isProduction,
|
|
471
|
+
{},
|
|
472
|
+
sourceMap,
|
|
473
|
+
{
|
|
474
|
+
isGlobal: globalSFCScope,
|
|
475
|
+
allowDynamic,
|
|
476
|
+
strictMessage,
|
|
477
|
+
escapeHtml,
|
|
478
|
+
jit: true,
|
|
479
|
+
onlyLocales,
|
|
480
|
+
forceStringify,
|
|
481
|
+
usedKeyFilter: collector ? (keyPath) => collector.shouldKeepKey(keyPath) : void 0
|
|
482
|
+
}
|
|
483
|
+
);
|
|
484
|
+
const { code: generatedCode } = await generate(code, parseOptions);
|
|
485
|
+
return {
|
|
486
|
+
moduleType: "js",
|
|
487
|
+
code: generatedCode,
|
|
488
|
+
map: { mappings: "" }
|
|
489
|
+
};
|
|
490
|
+
}
|
|
383
491
|
}
|
|
384
492
|
},
|
|
385
493
|
transform: {
|
|
386
494
|
async handler(code, id) {
|
|
495
|
+
if (isIntlifyVirtualId(id)) return;
|
|
387
496
|
const filter = await getFilter();
|
|
388
497
|
if (!filter(id)) {
|
|
389
498
|
return;
|
|
@@ -501,23 +610,23 @@ function getGenerator(ext, fallback = generateJSON) {
|
|
|
501
610
|
}
|
|
502
611
|
return fallback;
|
|
503
612
|
}
|
|
504
|
-
function normalizeConfigResolveAlias(
|
|
505
|
-
if (
|
|
506
|
-
return
|
|
613
|
+
function normalizeConfigResolveAlias(resolve2, framework) {
|
|
614
|
+
if (resolve2 && resolve2.alias) {
|
|
615
|
+
return resolve2;
|
|
507
616
|
}
|
|
508
|
-
if (!
|
|
617
|
+
if (!resolve2) {
|
|
509
618
|
if (framework === "vite") {
|
|
510
619
|
return { alias: [] };
|
|
511
620
|
} else if (framework === "webpack") {
|
|
512
621
|
return { alias: {} };
|
|
513
622
|
}
|
|
514
|
-
} else if (!
|
|
623
|
+
} else if (!resolve2.alias) {
|
|
515
624
|
if (framework === "vite") {
|
|
516
|
-
|
|
517
|
-
return
|
|
625
|
+
resolve2.alias = [];
|
|
626
|
+
return resolve2;
|
|
518
627
|
} else if (framework === "webpack") {
|
|
519
|
-
|
|
520
|
-
return
|
|
628
|
+
resolve2.alias = {};
|
|
629
|
+
return resolve2;
|
|
521
630
|
}
|
|
522
631
|
}
|
|
523
632
|
}
|
package/lib/vite.cjs
CHANGED
|
@@ -9,9 +9,9 @@ require('@intlify/bundle-utils');
|
|
|
9
9
|
require('@rollup/pluginutils');
|
|
10
10
|
require('fast-glob');
|
|
11
11
|
require('node:fs');
|
|
12
|
-
require('node:path');
|
|
13
12
|
require('vue/compiler-sfc');
|
|
14
13
|
require('picocolors');
|
|
14
|
+
require('node:path');
|
|
15
15
|
require('@eslint-community/eslint-utils');
|
|
16
16
|
require('@intlify/vue-i18n-extensions');
|
|
17
17
|
require('@typescript-eslint/scope-manager');
|
package/lib/vite.mjs
CHANGED
|
@@ -7,9 +7,9 @@ import '@intlify/bundle-utils';
|
|
|
7
7
|
import '@rollup/pluginutils';
|
|
8
8
|
import 'fast-glob';
|
|
9
9
|
import 'node:fs';
|
|
10
|
-
import 'node:path';
|
|
11
10
|
import 'vue/compiler-sfc';
|
|
12
11
|
import 'picocolors';
|
|
12
|
+
import 'node:path';
|
|
13
13
|
import '@eslint-community/eslint-utils';
|
|
14
14
|
import '@intlify/vue-i18n-extensions';
|
|
15
15
|
import '@typescript-eslint/scope-manager';
|
package/lib/webpack.cjs
CHANGED
|
@@ -9,9 +9,9 @@ require('@intlify/bundle-utils');
|
|
|
9
9
|
require('@rollup/pluginutils');
|
|
10
10
|
require('fast-glob');
|
|
11
11
|
require('node:fs');
|
|
12
|
-
require('node:path');
|
|
13
12
|
require('vue/compiler-sfc');
|
|
14
13
|
require('picocolors');
|
|
14
|
+
require('node:path');
|
|
15
15
|
require('@eslint-community/eslint-utils');
|
|
16
16
|
require('@intlify/vue-i18n-extensions');
|
|
17
17
|
require('@typescript-eslint/scope-manager');
|
package/lib/webpack.mjs
CHANGED
|
@@ -7,9 +7,9 @@ import '@intlify/bundle-utils';
|
|
|
7
7
|
import '@rollup/pluginutils';
|
|
8
8
|
import 'fast-glob';
|
|
9
9
|
import 'node:fs';
|
|
10
|
-
import 'node:path';
|
|
11
10
|
import 'vue/compiler-sfc';
|
|
12
11
|
import 'picocolors';
|
|
12
|
+
import 'node:path';
|
|
13
13
|
import '@eslint-community/eslint-utils';
|
|
14
14
|
import '@intlify/vue-i18n-extensions';
|
|
15
15
|
import '@typescript-eslint/scope-manager';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlify/unplugin-vue-i18n",
|
|
3
|
-
"version": "11.2.
|
|
3
|
+
"version": "11.2.1",
|
|
4
4
|
"description": "unplugin for Vue I18n",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "kazuya kawaguchi",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"picocolors": "^1.0.0",
|
|
40
40
|
"unplugin": "^2.3.4",
|
|
41
41
|
"vue": "~3.5.34",
|
|
42
|
-
"@intlify/bundle-utils": "11.2.
|
|
42
|
+
"@intlify/bundle-utils": "11.2.1"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@intlify/core-base": "next",
|
|
@@ -47,13 +47,13 @@
|
|
|
47
47
|
"@types/jsdom": "^16.2.5",
|
|
48
48
|
"@types/memory-fs": "^0.3.2",
|
|
49
49
|
"@types/node": "^25.7.0",
|
|
50
|
-
"@vitejs/plugin-vue": "
|
|
50
|
+
"@vitejs/plugin-vue": "^6.0.6",
|
|
51
51
|
"jsdom": "^25.0.1",
|
|
52
52
|
"memory-fs": "^0.5.0",
|
|
53
53
|
"source-map-js": "^1.2.1",
|
|
54
54
|
"ts-loader": "~9.5.7",
|
|
55
55
|
"unbuild": "^3.6.1",
|
|
56
|
-
"vite": "
|
|
56
|
+
"vite": "^8.0.0",
|
|
57
57
|
"rollup-vite": "npm:vite@6.3.5",
|
|
58
58
|
"vue-loader": "~17.4.2",
|
|
59
59
|
"webpack": "~5.106.2",
|