@intlify/unplugin-vue-i18n 11.2.5 → 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 +26 -21
- package/lib/index.mjs +26 -19
- 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;
|
|
@@ -398,7 +395,7 @@ function resourcePlugin({
|
|
|
398
395
|
return intlifyVirtualize(virtualKey);
|
|
399
396
|
}
|
|
400
397
|
const idPath = id.split("?")[0];
|
|
401
|
-
if (
|
|
398
|
+
if (!/\.json5?$/.test(idPath)) return;
|
|
402
399
|
let resolvedPath;
|
|
403
400
|
if (idPath.startsWith(".")) {
|
|
404
401
|
const realImporter = importer && isIntlifyVirtualId(importer) ? virtualIdToRealPath.get(importer) : importer;
|
|
@@ -411,6 +408,8 @@ function resourcePlugin({
|
|
|
411
408
|
}
|
|
412
409
|
const filter = await getFilter();
|
|
413
410
|
if (!filter(resolvedPath)) return;
|
|
411
|
+
const stat = await node_fs.promises.stat(resolvedPath).catch(() => null);
|
|
412
|
+
if (!stat?.isFile()) return;
|
|
414
413
|
return intlifyVirtualize(resolvedPath);
|
|
415
414
|
}
|
|
416
415
|
}
|
|
@@ -421,7 +420,10 @@ function resourcePlugin({
|
|
|
421
420
|
if (INTLIFY_BUNDLE_IMPORT_ID === getVirtualId(id, meta.framework) && include) {
|
|
422
421
|
let resourcePaths = [];
|
|
423
422
|
for (const inc of include) {
|
|
424
|
-
resourcePaths = [
|
|
423
|
+
resourcePaths = [
|
|
424
|
+
...resourcePaths,
|
|
425
|
+
...await tinyglobby.glob(inc, { cwd: process.cwd(), expandDirectories: false, absolute: true })
|
|
426
|
+
];
|
|
425
427
|
}
|
|
426
428
|
resourcePaths = resourcePaths.filter((el, pos) => resourcePaths.indexOf(el) === pos);
|
|
427
429
|
const code = await generateBundleResources(resourcePaths, isProduction, {
|
|
@@ -969,15 +971,20 @@ function getImportLocalName(scope, source, imported) {
|
|
|
969
971
|
return null;
|
|
970
972
|
}
|
|
971
973
|
function getImportDeclaration(scope, source) {
|
|
972
|
-
const
|
|
973
|
-
const
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
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;
|
|
977
985
|
}
|
|
978
|
-
}
|
|
979
|
-
|
|
980
|
-
return refs.length ? refs[0].node : null;
|
|
986
|
+
}
|
|
987
|
+
return null;
|
|
981
988
|
}
|
|
982
989
|
function isImportedIdentifierInImportClause(node) {
|
|
983
990
|
return "imported" in node;
|
|
@@ -1002,7 +1009,7 @@ const EMPTY_NODE_RETURN = {
|
|
|
1002
1009
|
returnStatement: null
|
|
1003
1010
|
};
|
|
1004
1011
|
function getCallExpressionAndReturnStatement(scope, local) {
|
|
1005
|
-
const variable =
|
|
1012
|
+
const variable = findVariable(scope, local);
|
|
1006
1013
|
if (variable == null) {
|
|
1007
1014
|
return EMPTY_NODE_RETURN;
|
|
1008
1015
|
}
|
|
@@ -1013,16 +1020,12 @@ function getCallExpressionAndReturnStatement(scope, local) {
|
|
|
1013
1020
|
return EMPTY_NODE_RETURN;
|
|
1014
1021
|
}
|
|
1015
1022
|
let returnStatement = null;
|
|
1016
|
-
if (callExpressionRef.from.type === "function" && callExpressionRef.from.block.type === tsEstree.AST_NODE_TYPES.FunctionExpression &&
|
|
1017
|
-
callExpressionRef.from.block.parent.type === tsEstree.AST_NODE_TYPES.Property && // @ts-expect-error -- FIXME: type error
|
|
1018
|
-
callExpressionRef.from.block.parent.key.type === tsEstree.AST_NODE_TYPES.Identifier && // @ts-expect-error -- FIXME: type error
|
|
1019
|
-
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") {
|
|
1020
1024
|
returnStatement = callExpressionRef.from.block.body.body.find((statement) => {
|
|
1021
1025
|
return statement.type === tsEstree.AST_NODE_TYPES.ReturnStatement;
|
|
1022
1026
|
});
|
|
1023
1027
|
}
|
|
1024
1028
|
return {
|
|
1025
|
-
// @ts-expect-error -- FIXME: type error
|
|
1026
1029
|
callExpression: callExpressionRef.identifier.parent,
|
|
1027
1030
|
returnStatement
|
|
1028
1031
|
};
|
|
@@ -1327,8 +1330,10 @@ function treeShakingPlugin(resolvedOptions, collector) {
|
|
|
1327
1330
|
const treeShaking = resolvedOptions.treeShaking;
|
|
1328
1331
|
const patterns = treeShaking?.scanPatterns || [`${projectRoot}/src/**/*.{vue,ts,js,tsx,jsx}`];
|
|
1329
1332
|
debug$1("scanning patterns:", patterns);
|
|
1330
|
-
const files = await
|
|
1333
|
+
const files = await tinyglobby.glob(patterns, {
|
|
1334
|
+
cwd: process.cwd(),
|
|
1331
1335
|
ignore: ["**/node_modules/**"],
|
|
1336
|
+
expandDirectories: false,
|
|
1332
1337
|
absolute: true
|
|
1333
1338
|
});
|
|
1334
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
|
|
|
@@ -386,7 +385,7 @@ function resourcePlugin({
|
|
|
386
385
|
return intlifyVirtualize(virtualKey);
|
|
387
386
|
}
|
|
388
387
|
const idPath = id.split("?")[0];
|
|
389
|
-
if (
|
|
388
|
+
if (!/\.json5?$/.test(idPath)) return;
|
|
390
389
|
let resolvedPath;
|
|
391
390
|
if (idPath.startsWith(".")) {
|
|
392
391
|
const realImporter = importer && isIntlifyVirtualId(importer) ? virtualIdToRealPath.get(importer) : importer;
|
|
@@ -399,6 +398,8 @@ function resourcePlugin({
|
|
|
399
398
|
}
|
|
400
399
|
const filter = await getFilter();
|
|
401
400
|
if (!filter(resolvedPath)) return;
|
|
401
|
+
const stat = await promises.stat(resolvedPath).catch(() => null);
|
|
402
|
+
if (!stat?.isFile()) return;
|
|
402
403
|
return intlifyVirtualize(resolvedPath);
|
|
403
404
|
}
|
|
404
405
|
}
|
|
@@ -409,7 +410,10 @@ function resourcePlugin({
|
|
|
409
410
|
if (INTLIFY_BUNDLE_IMPORT_ID === getVirtualId(id, meta.framework) && include) {
|
|
410
411
|
let resourcePaths = [];
|
|
411
412
|
for (const inc of include) {
|
|
412
|
-
resourcePaths = [
|
|
413
|
+
resourcePaths = [
|
|
414
|
+
...resourcePaths,
|
|
415
|
+
...await glob(inc, { cwd: process.cwd(), expandDirectories: false, absolute: true })
|
|
416
|
+
];
|
|
413
417
|
}
|
|
414
418
|
resourcePaths = resourcePaths.filter((el, pos) => resourcePaths.indexOf(el) === pos);
|
|
415
419
|
const code = await generateBundleResources(resourcePaths, isProduction, {
|
|
@@ -957,15 +961,20 @@ function getImportLocalName(scope, source, imported) {
|
|
|
957
961
|
return null;
|
|
958
962
|
}
|
|
959
963
|
function getImportDeclaration(scope, source) {
|
|
960
|
-
const
|
|
961
|
-
const
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
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;
|
|
965
975
|
}
|
|
966
|
-
}
|
|
967
|
-
|
|
968
|
-
return refs.length ? refs[0].node : null;
|
|
976
|
+
}
|
|
977
|
+
return null;
|
|
969
978
|
}
|
|
970
979
|
function isImportedIdentifierInImportClause(node) {
|
|
971
980
|
return "imported" in node;
|
|
@@ -990,7 +999,7 @@ const EMPTY_NODE_RETURN = {
|
|
|
990
999
|
returnStatement: null
|
|
991
1000
|
};
|
|
992
1001
|
function getCallExpressionAndReturnStatement(scope, local) {
|
|
993
|
-
const variable =
|
|
1002
|
+
const variable = findVariable(scope, local);
|
|
994
1003
|
if (variable == null) {
|
|
995
1004
|
return EMPTY_NODE_RETURN;
|
|
996
1005
|
}
|
|
@@ -1001,16 +1010,12 @@ function getCallExpressionAndReturnStatement(scope, local) {
|
|
|
1001
1010
|
return EMPTY_NODE_RETURN;
|
|
1002
1011
|
}
|
|
1003
1012
|
let returnStatement = null;
|
|
1004
|
-
if (callExpressionRef.from.type === "function" && callExpressionRef.from.block.type === tsEstree.AST_NODE_TYPES.FunctionExpression &&
|
|
1005
|
-
callExpressionRef.from.block.parent.type === tsEstree.AST_NODE_TYPES.Property && // @ts-expect-error -- FIXME: type error
|
|
1006
|
-
callExpressionRef.from.block.parent.key.type === tsEstree.AST_NODE_TYPES.Identifier && // @ts-expect-error -- FIXME: type error
|
|
1007
|
-
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") {
|
|
1008
1014
|
returnStatement = callExpressionRef.from.block.body.body.find((statement) => {
|
|
1009
1015
|
return statement.type === tsEstree.AST_NODE_TYPES.ReturnStatement;
|
|
1010
1016
|
});
|
|
1011
1017
|
}
|
|
1012
1018
|
return {
|
|
1013
|
-
// @ts-expect-error -- FIXME: type error
|
|
1014
1019
|
callExpression: callExpressionRef.identifier.parent,
|
|
1015
1020
|
returnStatement
|
|
1016
1021
|
};
|
|
@@ -1315,8 +1320,10 @@ function treeShakingPlugin(resolvedOptions, collector) {
|
|
|
1315
1320
|
const treeShaking = resolvedOptions.treeShaking;
|
|
1316
1321
|
const patterns = treeShaking?.scanPatterns || [`${projectRoot}/src/**/*.{vue,ts,js,tsx,jsx}`];
|
|
1317
1322
|
debug$1("scanning patterns:", patterns);
|
|
1318
|
-
const files = await
|
|
1323
|
+
const files = await glob(patterns, {
|
|
1324
|
+
cwd: process.cwd(),
|
|
1319
1325
|
ignore: ["**/node_modules/**"],
|
|
1326
|
+
expandDirectories: false,
|
|
1320
1327
|
absolute: true
|
|
1321
1328
|
});
|
|
1322
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",
|