@intlify/unplugin-vue-i18n 11.2.4 → 11.2.6
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 +41 -30
- package/lib/index.mjs +41 -28
- package/lib/vite.cjs +1 -2
- package/lib/vite.mjs +1 -2
- package/lib/webpack.cjs +1 -2
- package/lib/webpack.mjs +1 -2
- package/package.json +3 -4
package/lib/index.cjs
CHANGED
|
@@ -8,22 +8,19 @@ const shared = require('@intlify/shared');
|
|
|
8
8
|
const pathe = require('pathe');
|
|
9
9
|
const bundleUtils = require('@intlify/bundle-utils');
|
|
10
10
|
const pluginutils = require('@rollup/pluginutils');
|
|
11
|
-
const fg = require('fast-glob');
|
|
12
11
|
const node_fs = require('node:fs');
|
|
12
|
+
const tinyglobby = require('tinyglobby');
|
|
13
13
|
const compilerSfc = require('vue/compiler-sfc');
|
|
14
14
|
const pc = require('picocolors');
|
|
15
15
|
const path = require('node:path');
|
|
16
|
-
const eslintUitls = require('@eslint-community/eslint-utils');
|
|
17
16
|
const vueI18nExtensions = require('@intlify/vue-i18n-extensions');
|
|
18
17
|
const scopeManager = require('@typescript-eslint/scope-manager');
|
|
19
18
|
|
|
20
19
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
21
20
|
|
|
22
21
|
const createDebug__default = /*#__PURE__*/_interopDefaultCompat(createDebug);
|
|
23
|
-
const fg__default = /*#__PURE__*/_interopDefaultCompat(fg);
|
|
24
22
|
const pc__default = /*#__PURE__*/_interopDefaultCompat(pc);
|
|
25
23
|
const path__default = /*#__PURE__*/_interopDefaultCompat(path);
|
|
26
|
-
const eslintUitls__default = /*#__PURE__*/_interopDefaultCompat(eslintUitls);
|
|
27
24
|
|
|
28
25
|
function normalizeGlobOption(val) {
|
|
29
26
|
if (!val) return void 0;
|
|
@@ -322,16 +319,22 @@ function resourcePlugin({
|
|
|
322
319
|
}
|
|
323
320
|
}
|
|
324
321
|
},
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
322
|
+
handleHotUpdate({ file, modules, server }) {
|
|
323
|
+
const key = pathe.normalize(file);
|
|
324
|
+
const virtualId = realPathToVirtualId.get(key);
|
|
325
|
+
const inBundle = !!(include && pluginutils.createFilter(include, exclude)(key));
|
|
326
|
+
if (!virtualId && !inBundle) return;
|
|
327
|
+
const affected = new Set(modules);
|
|
328
|
+
const addById = (id) => {
|
|
329
|
+
const mod = id && server.moduleGraph.getModuleById(id);
|
|
330
|
+
if (mod) affected.add(mod);
|
|
331
|
+
};
|
|
332
|
+
addById(virtualId);
|
|
333
|
+
if (inBundle) {
|
|
334
|
+
addById(asVirtualId(INTLIFY_BUNDLE_IMPORT_ID, meta.framework));
|
|
334
335
|
}
|
|
336
|
+
if (affected.size === modules.length) return;
|
|
337
|
+
return [...affected];
|
|
335
338
|
}
|
|
336
339
|
},
|
|
337
340
|
webpack(compiler) {
|
|
@@ -392,7 +395,7 @@ function resourcePlugin({
|
|
|
392
395
|
return intlifyVirtualize(virtualKey);
|
|
393
396
|
}
|
|
394
397
|
const idPath = id.split("?")[0];
|
|
395
|
-
if (
|
|
398
|
+
if (!/\.json5?$/.test(idPath)) return;
|
|
396
399
|
let resolvedPath;
|
|
397
400
|
if (idPath.startsWith(".")) {
|
|
398
401
|
const realImporter = importer && isIntlifyVirtualId(importer) ? virtualIdToRealPath.get(importer) : importer;
|
|
@@ -405,6 +408,8 @@ function resourcePlugin({
|
|
|
405
408
|
}
|
|
406
409
|
const filter = await getFilter();
|
|
407
410
|
if (!filter(resolvedPath)) return;
|
|
411
|
+
const stat = await node_fs.promises.stat(resolvedPath).catch(() => null);
|
|
412
|
+
if (!stat?.isFile()) return;
|
|
408
413
|
return intlifyVirtualize(resolvedPath);
|
|
409
414
|
}
|
|
410
415
|
}
|
|
@@ -415,7 +420,10 @@ function resourcePlugin({
|
|
|
415
420
|
if (INTLIFY_BUNDLE_IMPORT_ID === getVirtualId(id, meta.framework) && include) {
|
|
416
421
|
let resourcePaths = [];
|
|
417
422
|
for (const inc of include) {
|
|
418
|
-
resourcePaths = [
|
|
423
|
+
resourcePaths = [
|
|
424
|
+
...resourcePaths,
|
|
425
|
+
...await tinyglobby.glob(inc, { cwd: process.cwd(), expandDirectories: false, absolute: true })
|
|
426
|
+
];
|
|
419
427
|
}
|
|
420
428
|
resourcePaths = resourcePaths.filter((el, pos) => resourcePaths.indexOf(el) === pos);
|
|
421
429
|
const code = await generateBundleResources(resourcePaths, isProduction, {
|
|
@@ -963,15 +971,20 @@ function getImportLocalName(scope, source, imported) {
|
|
|
963
971
|
return null;
|
|
964
972
|
}
|
|
965
973
|
function getImportDeclaration(scope, source) {
|
|
966
|
-
const
|
|
967
|
-
const
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
974
|
+
const program = scope.block;
|
|
975
|
+
const importDecl = program.body.find(
|
|
976
|
+
(node) => node.type === tsEstree.AST_NODE_TYPES.ImportDeclaration && node.source.value === source
|
|
977
|
+
);
|
|
978
|
+
return importDecl ? importDecl : null;
|
|
979
|
+
}
|
|
980
|
+
function findVariable(scope, name) {
|
|
981
|
+
for (let current = scope; current != null; current = current.upper) {
|
|
982
|
+
const variable = current.set.get(name);
|
|
983
|
+
if (variable != null) {
|
|
984
|
+
return variable;
|
|
971
985
|
}
|
|
972
|
-
}
|
|
973
|
-
|
|
974
|
-
return refs.length ? refs[0].node : null;
|
|
986
|
+
}
|
|
987
|
+
return null;
|
|
975
988
|
}
|
|
976
989
|
function isImportedIdentifierInImportClause(node) {
|
|
977
990
|
return "imported" in node;
|
|
@@ -996,7 +1009,7 @@ const EMPTY_NODE_RETURN = {
|
|
|
996
1009
|
returnStatement: null
|
|
997
1010
|
};
|
|
998
1011
|
function getCallExpressionAndReturnStatement(scope, local) {
|
|
999
|
-
const variable =
|
|
1012
|
+
const variable = findVariable(scope, local);
|
|
1000
1013
|
if (variable == null) {
|
|
1001
1014
|
return EMPTY_NODE_RETURN;
|
|
1002
1015
|
}
|
|
@@ -1007,16 +1020,12 @@ function getCallExpressionAndReturnStatement(scope, local) {
|
|
|
1007
1020
|
return EMPTY_NODE_RETURN;
|
|
1008
1021
|
}
|
|
1009
1022
|
let returnStatement = null;
|
|
1010
|
-
if (callExpressionRef.from.type === "function" && callExpressionRef.from.block.type === tsEstree.AST_NODE_TYPES.FunctionExpression &&
|
|
1011
|
-
callExpressionRef.from.block.parent.type === tsEstree.AST_NODE_TYPES.Property && // @ts-expect-error -- FIXME: type error
|
|
1012
|
-
callExpressionRef.from.block.parent.key.type === tsEstree.AST_NODE_TYPES.Identifier && // @ts-expect-error -- FIXME: type error
|
|
1013
|
-
callExpressionRef.from.block.parent.key.name === "setup") {
|
|
1023
|
+
if (callExpressionRef.from.type === "function" && callExpressionRef.from.block.type === tsEstree.AST_NODE_TYPES.FunctionExpression && callExpressionRef.from.block.parent.type === tsEstree.AST_NODE_TYPES.Property && callExpressionRef.from.block.parent.key.type === tsEstree.AST_NODE_TYPES.Identifier && callExpressionRef.from.block.parent.key.name === "setup") {
|
|
1014
1024
|
returnStatement = callExpressionRef.from.block.body.body.find((statement) => {
|
|
1015
1025
|
return statement.type === tsEstree.AST_NODE_TYPES.ReturnStatement;
|
|
1016
1026
|
});
|
|
1017
1027
|
}
|
|
1018
1028
|
return {
|
|
1019
|
-
// @ts-expect-error -- FIXME: type error
|
|
1020
1029
|
callExpression: callExpressionRef.identifier.parent,
|
|
1021
1030
|
returnStatement
|
|
1022
1031
|
};
|
|
@@ -1321,8 +1330,10 @@ function treeShakingPlugin(resolvedOptions, collector) {
|
|
|
1321
1330
|
const treeShaking = resolvedOptions.treeShaking;
|
|
1322
1331
|
const patterns = treeShaking?.scanPatterns || [`${projectRoot}/src/**/*.{vue,ts,js,tsx,jsx}`];
|
|
1323
1332
|
debug$1("scanning patterns:", patterns);
|
|
1324
|
-
const files = await
|
|
1333
|
+
const files = await tinyglobby.glob(patterns, {
|
|
1334
|
+
cwd: process.cwd(),
|
|
1325
1335
|
ignore: ["**/node_modules/**"],
|
|
1336
|
+
expandDirectories: false,
|
|
1326
1337
|
absolute: true
|
|
1327
1338
|
});
|
|
1328
1339
|
debug$1(`found ${files.length} source files to scan`);
|
package/lib/index.mjs
CHANGED
|
@@ -4,12 +4,11 @@ import { isArray, isString, isBoolean, assign, isEmptyObject, isNumber, generate
|
|
|
4
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
|
-
import fg from 'fast-glob';
|
|
8
7
|
import { promises } from 'node:fs';
|
|
8
|
+
import { glob } from 'tinyglobby';
|
|
9
9
|
import { parse as parse$1 } from 'vue/compiler-sfc';
|
|
10
10
|
import pc from 'picocolors';
|
|
11
11
|
import path from 'node:path';
|
|
12
|
-
import eslintUitls from '@eslint-community/eslint-utils';
|
|
13
12
|
import { transformVTDirective } from '@intlify/vue-i18n-extensions';
|
|
14
13
|
import { analyze } from '@typescript-eslint/scope-manager';
|
|
15
14
|
|
|
@@ -310,16 +309,22 @@ function resourcePlugin({
|
|
|
310
309
|
}
|
|
311
310
|
}
|
|
312
311
|
},
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
312
|
+
handleHotUpdate({ file, modules, server }) {
|
|
313
|
+
const key = normalize(file);
|
|
314
|
+
const virtualId = realPathToVirtualId.get(key);
|
|
315
|
+
const inBundle = !!(include && createFilter(include, exclude)(key));
|
|
316
|
+
if (!virtualId && !inBundle) return;
|
|
317
|
+
const affected = new Set(modules);
|
|
318
|
+
const addById = (id) => {
|
|
319
|
+
const mod = id && server.moduleGraph.getModuleById(id);
|
|
320
|
+
if (mod) affected.add(mod);
|
|
321
|
+
};
|
|
322
|
+
addById(virtualId);
|
|
323
|
+
if (inBundle) {
|
|
324
|
+
addById(asVirtualId(INTLIFY_BUNDLE_IMPORT_ID, meta.framework));
|
|
322
325
|
}
|
|
326
|
+
if (affected.size === modules.length) return;
|
|
327
|
+
return [...affected];
|
|
323
328
|
}
|
|
324
329
|
},
|
|
325
330
|
webpack(compiler) {
|
|
@@ -380,7 +385,7 @@ function resourcePlugin({
|
|
|
380
385
|
return intlifyVirtualize(virtualKey);
|
|
381
386
|
}
|
|
382
387
|
const idPath = id.split("?")[0];
|
|
383
|
-
if (
|
|
388
|
+
if (!/\.json5?$/.test(idPath)) return;
|
|
384
389
|
let resolvedPath;
|
|
385
390
|
if (idPath.startsWith(".")) {
|
|
386
391
|
const realImporter = importer && isIntlifyVirtualId(importer) ? virtualIdToRealPath.get(importer) : importer;
|
|
@@ -393,6 +398,8 @@ function resourcePlugin({
|
|
|
393
398
|
}
|
|
394
399
|
const filter = await getFilter();
|
|
395
400
|
if (!filter(resolvedPath)) return;
|
|
401
|
+
const stat = await promises.stat(resolvedPath).catch(() => null);
|
|
402
|
+
if (!stat?.isFile()) return;
|
|
396
403
|
return intlifyVirtualize(resolvedPath);
|
|
397
404
|
}
|
|
398
405
|
}
|
|
@@ -403,7 +410,10 @@ function resourcePlugin({
|
|
|
403
410
|
if (INTLIFY_BUNDLE_IMPORT_ID === getVirtualId(id, meta.framework) && include) {
|
|
404
411
|
let resourcePaths = [];
|
|
405
412
|
for (const inc of include) {
|
|
406
|
-
resourcePaths = [
|
|
413
|
+
resourcePaths = [
|
|
414
|
+
...resourcePaths,
|
|
415
|
+
...await glob(inc, { cwd: process.cwd(), expandDirectories: false, absolute: true })
|
|
416
|
+
];
|
|
407
417
|
}
|
|
408
418
|
resourcePaths = resourcePaths.filter((el, pos) => resourcePaths.indexOf(el) === pos);
|
|
409
419
|
const code = await generateBundleResources(resourcePaths, isProduction, {
|
|
@@ -951,15 +961,20 @@ function getImportLocalName(scope, source, imported) {
|
|
|
951
961
|
return null;
|
|
952
962
|
}
|
|
953
963
|
function getImportDeclaration(scope, source) {
|
|
954
|
-
const
|
|
955
|
-
const
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
964
|
+
const program = scope.block;
|
|
965
|
+
const importDecl = program.body.find(
|
|
966
|
+
(node) => node.type === tsEstree.AST_NODE_TYPES.ImportDeclaration && node.source.value === source
|
|
967
|
+
);
|
|
968
|
+
return importDecl ? importDecl : null;
|
|
969
|
+
}
|
|
970
|
+
function findVariable(scope, name) {
|
|
971
|
+
for (let current = scope; current != null; current = current.upper) {
|
|
972
|
+
const variable = current.set.get(name);
|
|
973
|
+
if (variable != null) {
|
|
974
|
+
return variable;
|
|
959
975
|
}
|
|
960
|
-
}
|
|
961
|
-
|
|
962
|
-
return refs.length ? refs[0].node : null;
|
|
976
|
+
}
|
|
977
|
+
return null;
|
|
963
978
|
}
|
|
964
979
|
function isImportedIdentifierInImportClause(node) {
|
|
965
980
|
return "imported" in node;
|
|
@@ -984,7 +999,7 @@ const EMPTY_NODE_RETURN = {
|
|
|
984
999
|
returnStatement: null
|
|
985
1000
|
};
|
|
986
1001
|
function getCallExpressionAndReturnStatement(scope, local) {
|
|
987
|
-
const variable =
|
|
1002
|
+
const variable = findVariable(scope, local);
|
|
988
1003
|
if (variable == null) {
|
|
989
1004
|
return EMPTY_NODE_RETURN;
|
|
990
1005
|
}
|
|
@@ -995,16 +1010,12 @@ function getCallExpressionAndReturnStatement(scope, local) {
|
|
|
995
1010
|
return EMPTY_NODE_RETURN;
|
|
996
1011
|
}
|
|
997
1012
|
let returnStatement = null;
|
|
998
|
-
if (callExpressionRef.from.type === "function" && callExpressionRef.from.block.type === tsEstree.AST_NODE_TYPES.FunctionExpression &&
|
|
999
|
-
callExpressionRef.from.block.parent.type === tsEstree.AST_NODE_TYPES.Property && // @ts-expect-error -- FIXME: type error
|
|
1000
|
-
callExpressionRef.from.block.parent.key.type === tsEstree.AST_NODE_TYPES.Identifier && // @ts-expect-error -- FIXME: type error
|
|
1001
|
-
callExpressionRef.from.block.parent.key.name === "setup") {
|
|
1013
|
+
if (callExpressionRef.from.type === "function" && callExpressionRef.from.block.type === tsEstree.AST_NODE_TYPES.FunctionExpression && callExpressionRef.from.block.parent.type === tsEstree.AST_NODE_TYPES.Property && callExpressionRef.from.block.parent.key.type === tsEstree.AST_NODE_TYPES.Identifier && callExpressionRef.from.block.parent.key.name === "setup") {
|
|
1002
1014
|
returnStatement = callExpressionRef.from.block.body.body.find((statement) => {
|
|
1003
1015
|
return statement.type === tsEstree.AST_NODE_TYPES.ReturnStatement;
|
|
1004
1016
|
});
|
|
1005
1017
|
}
|
|
1006
1018
|
return {
|
|
1007
|
-
// @ts-expect-error -- FIXME: type error
|
|
1008
1019
|
callExpression: callExpressionRef.identifier.parent,
|
|
1009
1020
|
returnStatement
|
|
1010
1021
|
};
|
|
@@ -1309,8 +1320,10 @@ function treeShakingPlugin(resolvedOptions, collector) {
|
|
|
1309
1320
|
const treeShaking = resolvedOptions.treeShaking;
|
|
1310
1321
|
const patterns = treeShaking?.scanPatterns || [`${projectRoot}/src/**/*.{vue,ts,js,tsx,jsx}`];
|
|
1311
1322
|
debug$1("scanning patterns:", patterns);
|
|
1312
|
-
const files = await
|
|
1323
|
+
const files = await glob(patterns, {
|
|
1324
|
+
cwd: process.cwd(),
|
|
1313
1325
|
ignore: ["**/node_modules/**"],
|
|
1326
|
+
expandDirectories: false,
|
|
1314
1327
|
absolute: true
|
|
1315
1328
|
});
|
|
1316
1329
|
debug$1(`found ${files.length} source files to scan`);
|
package/lib/vite.cjs
CHANGED
|
@@ -7,12 +7,11 @@ require('@intlify/shared');
|
|
|
7
7
|
require('pathe');
|
|
8
8
|
require('@intlify/bundle-utils');
|
|
9
9
|
require('@rollup/pluginutils');
|
|
10
|
-
require('fast-glob');
|
|
11
10
|
require('node:fs');
|
|
11
|
+
require('tinyglobby');
|
|
12
12
|
require('vue/compiler-sfc');
|
|
13
13
|
require('picocolors');
|
|
14
14
|
require('node:path');
|
|
15
|
-
require('@eslint-community/eslint-utils');
|
|
16
15
|
require('@intlify/vue-i18n-extensions');
|
|
17
16
|
require('@typescript-eslint/scope-manager');
|
|
18
17
|
|
package/lib/vite.mjs
CHANGED
|
@@ -5,12 +5,11 @@ import '@intlify/shared';
|
|
|
5
5
|
import 'pathe';
|
|
6
6
|
import '@intlify/bundle-utils';
|
|
7
7
|
import '@rollup/pluginutils';
|
|
8
|
-
import 'fast-glob';
|
|
9
8
|
import 'node:fs';
|
|
9
|
+
import 'tinyglobby';
|
|
10
10
|
import 'vue/compiler-sfc';
|
|
11
11
|
import 'picocolors';
|
|
12
12
|
import 'node:path';
|
|
13
|
-
import '@eslint-community/eslint-utils';
|
|
14
13
|
import '@intlify/vue-i18n-extensions';
|
|
15
14
|
import '@typescript-eslint/scope-manager';
|
|
16
15
|
|
package/lib/webpack.cjs
CHANGED
|
@@ -7,12 +7,11 @@ require('@intlify/shared');
|
|
|
7
7
|
require('pathe');
|
|
8
8
|
require('@intlify/bundle-utils');
|
|
9
9
|
require('@rollup/pluginutils');
|
|
10
|
-
require('fast-glob');
|
|
11
10
|
require('node:fs');
|
|
11
|
+
require('tinyglobby');
|
|
12
12
|
require('vue/compiler-sfc');
|
|
13
13
|
require('picocolors');
|
|
14
14
|
require('node:path');
|
|
15
|
-
require('@eslint-community/eslint-utils');
|
|
16
15
|
require('@intlify/vue-i18n-extensions');
|
|
17
16
|
require('@typescript-eslint/scope-manager');
|
|
18
17
|
|
package/lib/webpack.mjs
CHANGED
|
@@ -5,12 +5,11 @@ import '@intlify/shared';
|
|
|
5
5
|
import 'pathe';
|
|
6
6
|
import '@intlify/bundle-utils';
|
|
7
7
|
import '@rollup/pluginutils';
|
|
8
|
-
import 'fast-glob';
|
|
9
8
|
import 'node:fs';
|
|
9
|
+
import 'tinyglobby';
|
|
10
10
|
import 'vue/compiler-sfc';
|
|
11
11
|
import 'picocolors';
|
|
12
12
|
import 'node:path';
|
|
13
|
-
import '@eslint-community/eslint-utils';
|
|
14
13
|
import '@intlify/vue-i18n-extensions';
|
|
15
14
|
import '@typescript-eslint/scope-manager';
|
|
16
15
|
|
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.6",
|
|
4
4
|
"description": "unplugin for Vue I18n",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "kazuya kawaguchi",
|
|
@@ -27,7 +27,6 @@
|
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@eslint-community/eslint-utils": "^4.4.0",
|
|
31
30
|
"@intlify/shared": "~11.4.2",
|
|
32
31
|
"@intlify/vue-i18n-extensions": "^8.0.0",
|
|
33
32
|
"@rollup/pluginutils": "^5.1.0",
|
|
@@ -35,11 +34,11 @@
|
|
|
35
34
|
"@typescript-eslint/typescript-estree": "^8.13.0",
|
|
36
35
|
"debug": "^4.3.3",
|
|
37
36
|
"pathe": "^2.0.3",
|
|
38
|
-
"fast-glob": "^3.2.12",
|
|
39
37
|
"picocolors": "^1.0.0",
|
|
38
|
+
"tinyglobby": "^0.2.15",
|
|
40
39
|
"unplugin": "^2.3.4",
|
|
41
40
|
"vue": "~3.5.34",
|
|
42
|
-
"@intlify/bundle-utils": "11.2.
|
|
41
|
+
"@intlify/bundle-utils": "11.2.6"
|
|
43
42
|
},
|
|
44
43
|
"devDependencies": {
|
|
45
44
|
"@intlify/core-base": "next",
|