@intlify/bundle-utils 7.4.0 → 7.5.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/lib/index.cjs +9 -4
- package/lib/index.d.cts +3 -2
- package/lib/index.d.mts +3 -2
- package/lib/index.d.ts +3 -2
- package/lib/index.mjs +9 -4
- package/package.json +2 -2
package/lib/index.cjs
CHANGED
|
@@ -275,8 +275,11 @@ function excludeLocales({
|
|
|
275
275
|
return _messages;
|
|
276
276
|
}
|
|
277
277
|
|
|
278
|
-
function generateLegacyCode({
|
|
279
|
-
|
|
278
|
+
function generateLegacyCode({
|
|
279
|
+
isGlobal = false,
|
|
280
|
+
vueVersion = "v2.6"
|
|
281
|
+
}, generator) {
|
|
282
|
+
const componentNamespace = `Component${vueVersion === "v2.6" ? ".options" : ""}`;
|
|
280
283
|
const variableName = !isGlobal ? "__i18n" : "__i18nGlobal";
|
|
281
284
|
const exportSyntax = "export default";
|
|
282
285
|
const code = `${exportSyntax} function (Component) {
|
|
@@ -292,6 +295,7 @@ function generateLegacyCode({ isGlobal }, generator) {
|
|
|
292
295
|
function generate$2(targetSource, {
|
|
293
296
|
type = "plain",
|
|
294
297
|
legacy = false,
|
|
298
|
+
vueVersion = "v2.6",
|
|
295
299
|
bridge = false,
|
|
296
300
|
onlyLocales = [],
|
|
297
301
|
exportESM = false,
|
|
@@ -341,7 +345,7 @@ function generate$2(targetSource, {
|
|
|
341
345
|
}
|
|
342
346
|
if (legacy && type === "sfc") {
|
|
343
347
|
const gen = () => shared.friendlyJSONstringify(jsoncEslintParser.getStaticJSONValue(ast));
|
|
344
|
-
const code2 = generateLegacyCode(
|
|
348
|
+
const code2 = generateLegacyCode({ isGlobal, vueVersion }, gen);
|
|
345
349
|
const s = new MagicString__default(code2);
|
|
346
350
|
return {
|
|
347
351
|
ast,
|
|
@@ -562,6 +566,7 @@ function _generate$2(generator, node, options = {}, injector) {
|
|
|
562
566
|
function generate$1(targetSource, {
|
|
563
567
|
type = "plain",
|
|
564
568
|
legacy = false,
|
|
569
|
+
vueVersion = "v2.6",
|
|
565
570
|
bridge = false,
|
|
566
571
|
onlyLocales = [],
|
|
567
572
|
exportESM = false,
|
|
@@ -611,7 +616,7 @@ function generate$1(targetSource, {
|
|
|
611
616
|
}
|
|
612
617
|
if (legacy && type === "sfc") {
|
|
613
618
|
const gen = () => shared.friendlyJSONstringify(yamlEslintParser.getStaticYAMLValue(ast));
|
|
614
|
-
const code2 = generateLegacyCode(
|
|
619
|
+
const code2 = generateLegacyCode({ isGlobal, vueVersion }, gen);
|
|
615
620
|
const s = new MagicString__default(code2);
|
|
616
621
|
return {
|
|
617
622
|
ast,
|
package/lib/index.d.cts
CHANGED
|
@@ -16,6 +16,7 @@ type DevEnv = 'development' | 'production';
|
|
|
16
16
|
interface CodeGenOptions {
|
|
17
17
|
type?: 'plain' | 'sfc' | 'bare';
|
|
18
18
|
legacy?: boolean;
|
|
19
|
+
vueVersion?: 'v2.6' | 'v2.7';
|
|
19
20
|
bridge?: boolean;
|
|
20
21
|
exportESM?: boolean;
|
|
21
22
|
onlyLocales?: string[];
|
|
@@ -53,7 +54,7 @@ interface CodeGenResult<ASTNode, CodeGenError extends Error = Error> {
|
|
|
53
54
|
* Code / AST generator for i18n json/json5 resource
|
|
54
55
|
*/
|
|
55
56
|
|
|
56
|
-
declare function generate$2(targetSource: string | Buffer, { type, legacy, bridge, onlyLocales, exportESM, filename, inSourceMap, locale, isGlobal, sourceMap, env, forceStringify, onError, strictMessage, escapeHtml, useClassComponent, jit }: CodeGenOptions, injector?: () => string): CodeGenResult<JSONProgram>;
|
|
57
|
+
declare function generate$2(targetSource: string | Buffer, { type, legacy, vueVersion, bridge, onlyLocales, exportESM, filename, inSourceMap, locale, isGlobal, sourceMap, env, forceStringify, onError, strictMessage, escapeHtml, useClassComponent, jit }: CodeGenOptions, injector?: () => string): CodeGenResult<JSONProgram>;
|
|
57
58
|
|
|
58
59
|
/**
|
|
59
60
|
* Code generator for i18n yaml resource
|
|
@@ -62,7 +63,7 @@ declare function generate$2(targetSource: string | Buffer, { type, legacy, bridg
|
|
|
62
63
|
/**
|
|
63
64
|
* @internal
|
|
64
65
|
*/
|
|
65
|
-
declare function generate$1(targetSource: string | Buffer, { type, legacy, bridge, onlyLocales, exportESM, useClassComponent, filename, inSourceMap, locale, isGlobal, sourceMap, env, forceStringify, onError, strictMessage, escapeHtml, jit }: CodeGenOptions, injector?: () => string): CodeGenResult<YAMLProgram>;
|
|
66
|
+
declare function generate$1(targetSource: string | Buffer, { type, legacy, vueVersion, bridge, onlyLocales, exportESM, useClassComponent, filename, inSourceMap, locale, isGlobal, sourceMap, env, forceStringify, onError, strictMessage, escapeHtml, jit }: CodeGenOptions, injector?: () => string): CodeGenResult<YAMLProgram>;
|
|
66
67
|
|
|
67
68
|
/**
|
|
68
69
|
* Code generator for i18n js resource
|
package/lib/index.d.mts
CHANGED
|
@@ -16,6 +16,7 @@ type DevEnv = 'development' | 'production';
|
|
|
16
16
|
interface CodeGenOptions {
|
|
17
17
|
type?: 'plain' | 'sfc' | 'bare';
|
|
18
18
|
legacy?: boolean;
|
|
19
|
+
vueVersion?: 'v2.6' | 'v2.7';
|
|
19
20
|
bridge?: boolean;
|
|
20
21
|
exportESM?: boolean;
|
|
21
22
|
onlyLocales?: string[];
|
|
@@ -53,7 +54,7 @@ interface CodeGenResult<ASTNode, CodeGenError extends Error = Error> {
|
|
|
53
54
|
* Code / AST generator for i18n json/json5 resource
|
|
54
55
|
*/
|
|
55
56
|
|
|
56
|
-
declare function generate$2(targetSource: string | Buffer, { type, legacy, bridge, onlyLocales, exportESM, filename, inSourceMap, locale, isGlobal, sourceMap, env, forceStringify, onError, strictMessage, escapeHtml, useClassComponent, jit }: CodeGenOptions, injector?: () => string): CodeGenResult<JSONProgram>;
|
|
57
|
+
declare function generate$2(targetSource: string | Buffer, { type, legacy, vueVersion, bridge, onlyLocales, exportESM, filename, inSourceMap, locale, isGlobal, sourceMap, env, forceStringify, onError, strictMessage, escapeHtml, useClassComponent, jit }: CodeGenOptions, injector?: () => string): CodeGenResult<JSONProgram>;
|
|
57
58
|
|
|
58
59
|
/**
|
|
59
60
|
* Code generator for i18n yaml resource
|
|
@@ -62,7 +63,7 @@ declare function generate$2(targetSource: string | Buffer, { type, legacy, bridg
|
|
|
62
63
|
/**
|
|
63
64
|
* @internal
|
|
64
65
|
*/
|
|
65
|
-
declare function generate$1(targetSource: string | Buffer, { type, legacy, bridge, onlyLocales, exportESM, useClassComponent, filename, inSourceMap, locale, isGlobal, sourceMap, env, forceStringify, onError, strictMessage, escapeHtml, jit }: CodeGenOptions, injector?: () => string): CodeGenResult<YAMLProgram>;
|
|
66
|
+
declare function generate$1(targetSource: string | Buffer, { type, legacy, vueVersion, bridge, onlyLocales, exportESM, useClassComponent, filename, inSourceMap, locale, isGlobal, sourceMap, env, forceStringify, onError, strictMessage, escapeHtml, jit }: CodeGenOptions, injector?: () => string): CodeGenResult<YAMLProgram>;
|
|
66
67
|
|
|
67
68
|
/**
|
|
68
69
|
* Code generator for i18n js resource
|
package/lib/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ type DevEnv = 'development' | 'production';
|
|
|
16
16
|
interface CodeGenOptions {
|
|
17
17
|
type?: 'plain' | 'sfc' | 'bare';
|
|
18
18
|
legacy?: boolean;
|
|
19
|
+
vueVersion?: 'v2.6' | 'v2.7';
|
|
19
20
|
bridge?: boolean;
|
|
20
21
|
exportESM?: boolean;
|
|
21
22
|
onlyLocales?: string[];
|
|
@@ -53,7 +54,7 @@ interface CodeGenResult<ASTNode, CodeGenError extends Error = Error> {
|
|
|
53
54
|
* Code / AST generator for i18n json/json5 resource
|
|
54
55
|
*/
|
|
55
56
|
|
|
56
|
-
declare function generate$2(targetSource: string | Buffer, { type, legacy, bridge, onlyLocales, exportESM, filename, inSourceMap, locale, isGlobal, sourceMap, env, forceStringify, onError, strictMessage, escapeHtml, useClassComponent, jit }: CodeGenOptions, injector?: () => string): CodeGenResult<JSONProgram>;
|
|
57
|
+
declare function generate$2(targetSource: string | Buffer, { type, legacy, vueVersion, bridge, onlyLocales, exportESM, filename, inSourceMap, locale, isGlobal, sourceMap, env, forceStringify, onError, strictMessage, escapeHtml, useClassComponent, jit }: CodeGenOptions, injector?: () => string): CodeGenResult<JSONProgram>;
|
|
57
58
|
|
|
58
59
|
/**
|
|
59
60
|
* Code generator for i18n yaml resource
|
|
@@ -62,7 +63,7 @@ declare function generate$2(targetSource: string | Buffer, { type, legacy, bridg
|
|
|
62
63
|
/**
|
|
63
64
|
* @internal
|
|
64
65
|
*/
|
|
65
|
-
declare function generate$1(targetSource: string | Buffer, { type, legacy, bridge, onlyLocales, exportESM, useClassComponent, filename, inSourceMap, locale, isGlobal, sourceMap, env, forceStringify, onError, strictMessage, escapeHtml, jit }: CodeGenOptions, injector?: () => string): CodeGenResult<YAMLProgram>;
|
|
66
|
+
declare function generate$1(targetSource: string | Buffer, { type, legacy, vueVersion, bridge, onlyLocales, exportESM, useClassComponent, filename, inSourceMap, locale, isGlobal, sourceMap, env, forceStringify, onError, strictMessage, escapeHtml, jit }: CodeGenOptions, injector?: () => string): CodeGenResult<YAMLProgram>;
|
|
66
67
|
|
|
67
68
|
/**
|
|
68
69
|
* Code generator for i18n js resource
|
package/lib/index.mjs
CHANGED
|
@@ -267,8 +267,11 @@ function excludeLocales({
|
|
|
267
267
|
return _messages;
|
|
268
268
|
}
|
|
269
269
|
|
|
270
|
-
function generateLegacyCode({
|
|
271
|
-
|
|
270
|
+
function generateLegacyCode({
|
|
271
|
+
isGlobal = false,
|
|
272
|
+
vueVersion = "v2.6"
|
|
273
|
+
}, generator) {
|
|
274
|
+
const componentNamespace = `Component${vueVersion === "v2.6" ? ".options" : ""}`;
|
|
272
275
|
const variableName = !isGlobal ? "__i18n" : "__i18nGlobal";
|
|
273
276
|
const exportSyntax = "export default";
|
|
274
277
|
const code = `${exportSyntax} function (Component) {
|
|
@@ -284,6 +287,7 @@ function generateLegacyCode({ isGlobal }, generator) {
|
|
|
284
287
|
function generate$2(targetSource, {
|
|
285
288
|
type = "plain",
|
|
286
289
|
legacy = false,
|
|
290
|
+
vueVersion = "v2.6",
|
|
287
291
|
bridge = false,
|
|
288
292
|
onlyLocales = [],
|
|
289
293
|
exportESM = false,
|
|
@@ -333,7 +337,7 @@ function generate$2(targetSource, {
|
|
|
333
337
|
}
|
|
334
338
|
if (legacy && type === "sfc") {
|
|
335
339
|
const gen = () => friendlyJSONstringify(getStaticJSONValue(ast));
|
|
336
|
-
const code2 = generateLegacyCode(
|
|
340
|
+
const code2 = generateLegacyCode({ isGlobal, vueVersion }, gen);
|
|
337
341
|
const s = new MagicString(code2);
|
|
338
342
|
return {
|
|
339
343
|
ast,
|
|
@@ -554,6 +558,7 @@ function _generate$2(generator, node, options = {}, injector) {
|
|
|
554
558
|
function generate$1(targetSource, {
|
|
555
559
|
type = "plain",
|
|
556
560
|
legacy = false,
|
|
561
|
+
vueVersion = "v2.6",
|
|
557
562
|
bridge = false,
|
|
558
563
|
onlyLocales = [],
|
|
559
564
|
exportESM = false,
|
|
@@ -603,7 +608,7 @@ function generate$1(targetSource, {
|
|
|
603
608
|
}
|
|
604
609
|
if (legacy && type === "sfc") {
|
|
605
610
|
const gen = () => friendlyJSONstringify(getStaticYAMLValue(ast));
|
|
606
|
-
const code2 = generateLegacyCode(
|
|
611
|
+
const code2 = generateLegacyCode({ isGlobal, vueVersion }, gen);
|
|
607
612
|
const s = new MagicString(code2);
|
|
608
613
|
return {
|
|
609
614
|
ast,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlify/bundle-utils",
|
|
3
3
|
"description": "Bundle utilities for Intlify project",
|
|
4
|
-
"version": "7.
|
|
4
|
+
"version": "7.5.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "kazuya kawaguchi",
|
|
7
7
|
"email": "kawakazu80@gmail.com"
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"yaml-eslint-parser": "^1.2.2"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@types/escodegen": "^0.0.
|
|
33
|
+
"@types/escodegen": "^0.0.10",
|
|
34
34
|
"@types/estree": "^1.0.0",
|
|
35
35
|
"unbuild": "^2.0.0"
|
|
36
36
|
},
|