@intlify/bundle-utils 8.0.0 → 9.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/lib/index.cjs CHANGED
@@ -286,7 +286,6 @@ function generate$2(targetSource, {
286
286
  onError = void 0,
287
287
  strictMessage = true,
288
288
  escapeHtml = false,
289
- useClassComponent = false,
290
289
  jit = false
291
290
  }) {
292
291
  let value = Buffer.isBuffer(targetSource) ? targetSource.toString() : targetSource;
@@ -303,10 +302,8 @@ function generate$2(targetSource, {
303
302
  onError,
304
303
  strictMessage,
305
304
  escapeHtml,
306
- useClassComponent,
307
305
  jit
308
306
  };
309
- const generator = createCodeGenerator(options);
310
307
  let ast = jsoncEslintParser.parseJSON(value, { filePath: filename });
311
308
  if (!locale && type === "sfc" && onlyLocales?.length) {
312
309
  const messages = jsoncEslintParser.getStaticJSONValue(ast);
@@ -318,6 +315,13 @@ function generate$2(targetSource, {
318
315
  );
319
316
  ast = jsoncEslintParser.parseJSON(value, { filePath: filename });
320
317
  }
318
+ if (locale && onlyLocales?.length && !onlyLocales.includes(locale)) {
319
+ value = JSON.stringify({});
320
+ ast = jsoncEslintParser.parseJSON(value, { filePath: filename });
321
+ options.locale = "";
322
+ options.source = void 0;
323
+ }
324
+ const generator = createCodeGenerator(options);
321
325
  const codeMaps = _generate$2(generator, ast, options);
322
326
  const { code, map } = generator.context();
323
327
  const newMap = map && !jit ? mapLinesColumns(map.toJSON(), codeMaps, inSourceMap) || null : null;
@@ -333,7 +337,7 @@ function _generate$2(generator, node, options = {}) {
333
337
  const itemsCountStack = [];
334
338
  const { forceStringify } = generator.context();
335
339
  const codeMaps = /* @__PURE__ */ new Map();
336
- const { type, sourceMap, isGlobal, locale, useClassComponent, jit } = options;
340
+ const { type, sourceMap, isGlobal, locale, jit } = options;
337
341
  const codegenFn = jit ? generateResourceAst : generateMessageFunction;
338
342
  const componentNamespace = "_Component";
339
343
  jsoncEslintParser.traverseNodes(node, {
@@ -348,8 +352,10 @@ function _generate$2(generator, node, options = {}) {
348
352
  const exportSyntax = "export default";
349
353
  generator.push(`${exportSyntax} function (Component) {`);
350
354
  generator.indent();
351
- const componentVariable = useClassComponent ? `Component.__o || Component.__vccOpts || Component` : `Component`;
352
- generator.pushline(`const ${componentNamespace} = ${componentVariable}`);
355
+ const componentVariable = `Component`;
356
+ generator.pushline(
357
+ `const ${componentNamespace} = ${componentVariable}`
358
+ );
353
359
  generator.pushline(
354
360
  `${componentNamespace}.${variableName} = ${componentNamespace}.${variableName} || []`
355
361
  );
@@ -508,7 +514,6 @@ function _generate$2(generator, node, options = {}) {
508
514
  function generate$1(targetSource, {
509
515
  type = "plain",
510
516
  onlyLocales = [],
511
- useClassComponent = false,
512
517
  filename = "vue-i18n-loader.yaml",
513
518
  inSourceMap = void 0,
514
519
  locale = "",
@@ -535,10 +540,8 @@ function generate$1(targetSource, {
535
540
  onError,
536
541
  strictMessage,
537
542
  escapeHtml,
538
- useClassComponent,
539
543
  jit
540
544
  };
541
- const generator = createCodeGenerator(options);
542
545
  let ast = yamlEslintParser.parseYAML(value, { filePath: filename });
543
546
  if (!locale && type === "sfc" && onlyLocales?.length) {
544
547
  const messages = yamlEslintParser.getStaticYAMLValue(ast);
@@ -550,6 +553,13 @@ function generate$1(targetSource, {
550
553
  );
551
554
  ast = yamlEslintParser.parseYAML(value, { filePath: filename });
552
555
  }
556
+ if (locale && onlyLocales?.length && !onlyLocales.includes(locale)) {
557
+ value = JSON.stringify({});
558
+ ast = yamlEslintParser.parseYAML(value, { filePath: filename });
559
+ options.locale = "";
560
+ options.source = void 0;
561
+ }
562
+ const generator = createCodeGenerator(options);
553
563
  const codeMaps = _generate$1(generator, ast, options);
554
564
  const { code, map } = generator.context();
555
565
  const newMap = map ? mapLinesColumns(map.toJSON(), codeMaps, inSourceMap) || null : null;
@@ -565,7 +575,7 @@ function _generate$1(generator, node, options = {}) {
565
575
  const itemsCountStack = [];
566
576
  const { forceStringify } = generator.context();
567
577
  const codeMaps = /* @__PURE__ */ new Map();
568
- const { type, sourceMap, isGlobal, locale, useClassComponent, jit } = options;
578
+ const { type, sourceMap, isGlobal, locale, jit } = options;
569
579
  const codegenFn = jit ? generateResourceAst : generateMessageFunction;
570
580
  const componentNamespace = "_Component";
571
581
  yamlEslintParser.traverseNodes(node, {
@@ -580,8 +590,10 @@ function _generate$1(generator, node, options = {}) {
580
590
  const exportSyntax = "export default";
581
591
  generator.push(`${exportSyntax} function (Component) {`);
582
592
  generator.indent();
583
- const componentVariable = useClassComponent ? `Component.__o || Component.__vccOpts || Component` : `Component`;
584
- generator.pushline(`const ${componentNamespace} = ${componentVariable}`);
593
+ const componentVariable = `Component`;
594
+ generator.pushline(
595
+ `const ${componentNamespace} = ${componentVariable}`
596
+ );
585
597
  generator.pushline(
586
598
  `${componentNamespace}.${variableName} = ${componentNamespace}.${variableName} || []`
587
599
  );
@@ -749,7 +761,6 @@ function generate(targetSource, {
749
761
  onError = void 0,
750
762
  strictMessage = true,
751
763
  escapeHtml = false,
752
- useClassComponent = false,
753
764
  allowDynamic = false,
754
765
  jit = false
755
766
  }) {
@@ -768,7 +779,6 @@ function generate(targetSource, {
768
779
  onError,
769
780
  strictMessage,
770
781
  escapeHtml,
771
- useClassComponent,
772
782
  jit
773
783
  };
774
784
  const generator = createCodeGenerator(options);
@@ -836,7 +846,7 @@ function _generate(generator, node, options = {}) {
836
846
  const skipStack = [];
837
847
  const { forceStringify } = generator.context();
838
848
  const codeMaps = /* @__PURE__ */ new Map();
839
- const { type, sourceMap, isGlobal, locale, useClassComponent, jit } = options;
849
+ const { type, sourceMap, isGlobal, locale, jit } = options;
840
850
  const codegenFn = jit ? generateResourceAst : generateMessageFunction;
841
851
  const componentNamespace = "_Component";
842
852
  estreeWalker.walk(node, {
@@ -858,8 +868,10 @@ function _generate(generator, node, options = {}) {
858
868
  const exportSyntax = "export default";
859
869
  generator.push(`${exportSyntax} function (Component) {`);
860
870
  generator.indent();
861
- const componentVariable = useClassComponent ? `Component.__o || Component.__vccOpts || Component` : `Component`;
862
- generator.pushline(`const ${componentNamespace} = ${componentVariable}`);
871
+ const componentVariable = `Component`;
872
+ generator.pushline(
873
+ `const ${componentNamespace} = ${componentVariable}`
874
+ );
863
875
  generator.pushline(
864
876
  `${componentNamespace}.${variableName} = ${componentNamespace}.${variableName} || []`
865
877
  );
@@ -1094,17 +1106,17 @@ function checkInstallPackage(pkg, debug) {
1094
1106
  `${pkg} requires 'vue-i18n' or 'petite-vue-i18n' to be present in the dependency tree.`
1095
1107
  );
1096
1108
  }
1097
- function getVueI18nVersion(debug) {
1098
- const VueI18n = loadModule("vue-i18n", debug);
1109
+ function getVueI18nVersion(debug, pkg = "vue-i18n") {
1110
+ const VueI18n = loadModule(pkg, debug);
1099
1111
  if (VueI18n == null) {
1100
1112
  return "";
1101
1113
  }
1102
- if (VueI18n.version && VueI18n.version.startsWith("8.")) {
1103
- return "8";
1104
- }
1105
1114
  if (VueI18n.VERSION && VueI18n.VERSION.startsWith("9.")) {
1106
1115
  return "9";
1107
1116
  }
1117
+ if (VueI18n.VERSION && VueI18n.VERSION.startsWith("10.")) {
1118
+ return "10";
1119
+ }
1108
1120
  return "unknown";
1109
1121
  }
1110
1122
  function loadModule(moduleName, debug) {
package/lib/index.d.cts CHANGED
@@ -16,7 +16,6 @@ type DevEnv = 'development' | 'production';
16
16
  interface CodeGenOptions {
17
17
  type?: 'plain' | 'sfc' | 'bare';
18
18
  legacy?: boolean;
19
- vueVersion?: 'v2.6' | 'v2.7';
20
19
  bridge?: boolean;
21
20
  exportESM?: boolean;
22
21
  onlyLocales?: string[];
@@ -28,7 +27,6 @@ interface CodeGenOptions {
28
27
  locale?: string;
29
28
  env?: DevEnv;
30
29
  forceStringify?: boolean;
31
- useClassComponent?: boolean;
32
30
  allowDynamic?: boolean;
33
31
  strictMessage?: boolean;
34
32
  escapeHtml?: boolean;
@@ -54,7 +52,7 @@ interface CodeGenResult<ASTNode, CodeGenError extends Error = Error> {
54
52
  * Code / AST generator for i18n json/json5 resource
55
53
  */
56
54
 
57
- declare function generate$2(targetSource: string | Buffer, { type, onlyLocales, filename, inSourceMap, locale, isGlobal, sourceMap, env, forceStringify, onError, strictMessage, escapeHtml, useClassComponent, jit }: CodeGenOptions): CodeGenResult<JSONProgram>;
55
+ declare function generate$2(targetSource: string | Buffer, { type, onlyLocales, filename, inSourceMap, locale, isGlobal, sourceMap, env, forceStringify, onError, strictMessage, escapeHtml, jit }: CodeGenOptions): CodeGenResult<JSONProgram>;
58
56
 
59
57
  /**
60
58
  * Code generator for i18n yaml resource
@@ -63,7 +61,7 @@ declare function generate$2(targetSource: string | Buffer, { type, onlyLocales,
63
61
  /**
64
62
  * @internal
65
63
  */
66
- declare function generate$1(targetSource: string | Buffer, { type, onlyLocales, useClassComponent, filename, inSourceMap, locale, isGlobal, sourceMap, env, forceStringify, onError, strictMessage, escapeHtml, jit }: CodeGenOptions): CodeGenResult<YAMLProgram>;
64
+ declare function generate$1(targetSource: string | Buffer, { type, onlyLocales, filename, inSourceMap, locale, isGlobal, sourceMap, env, forceStringify, onError, strictMessage, escapeHtml, jit }: CodeGenOptions): CodeGenResult<YAMLProgram>;
67
65
 
68
66
  /**
69
67
  * Code generator for i18n js resource
@@ -72,11 +70,11 @@ declare function generate$1(targetSource: string | Buffer, { type, onlyLocales,
72
70
  /**
73
71
  * @internal
74
72
  */
75
- declare function generate(targetSource: string | Buffer, { type, filename, inSourceMap, locale, isGlobal, sourceMap, env, forceStringify, onError, strictMessage, escapeHtml, useClassComponent, allowDynamic, jit }: CodeGenOptions): CodeGenResult<Node>;
73
+ declare function generate(targetSource: string | Buffer, { type, filename, inSourceMap, locale, isGlobal, sourceMap, env, forceStringify, onError, strictMessage, escapeHtml, allowDynamic, jit }: CodeGenOptions): CodeGenResult<Node>;
76
74
 
77
75
  type InstalledPackage = 'vue-i18n' | 'petite-vue-i18n';
78
76
  declare function checkInstallPackage(pkg: string, debug: Function): InstalledPackage;
79
- type VueI18nVersion = '8' | '9' | 'unknown' | '';
80
- declare function getVueI18nVersion(debug: Function): VueI18nVersion;
77
+ type VueI18nVersion = '9' | '10' | 'unknown' | '';
78
+ declare function getVueI18nVersion(debug: Function, pkg?: string): VueI18nVersion;
81
79
 
82
80
  export { type CodeGenOptions, type CodeGenResult, type DevEnv, type InstalledPackage, checkInstallPackage, generate$2 as generateJSON, generate as generateJavaScript, generate$1 as generateYAML, getVueI18nVersion };
package/lib/index.d.mts CHANGED
@@ -16,7 +16,6 @@ type DevEnv = 'development' | 'production';
16
16
  interface CodeGenOptions {
17
17
  type?: 'plain' | 'sfc' | 'bare';
18
18
  legacy?: boolean;
19
- vueVersion?: 'v2.6' | 'v2.7';
20
19
  bridge?: boolean;
21
20
  exportESM?: boolean;
22
21
  onlyLocales?: string[];
@@ -28,7 +27,6 @@ interface CodeGenOptions {
28
27
  locale?: string;
29
28
  env?: DevEnv;
30
29
  forceStringify?: boolean;
31
- useClassComponent?: boolean;
32
30
  allowDynamic?: boolean;
33
31
  strictMessage?: boolean;
34
32
  escapeHtml?: boolean;
@@ -54,7 +52,7 @@ interface CodeGenResult<ASTNode, CodeGenError extends Error = Error> {
54
52
  * Code / AST generator for i18n json/json5 resource
55
53
  */
56
54
 
57
- declare function generate$2(targetSource: string | Buffer, { type, onlyLocales, filename, inSourceMap, locale, isGlobal, sourceMap, env, forceStringify, onError, strictMessage, escapeHtml, useClassComponent, jit }: CodeGenOptions): CodeGenResult<JSONProgram>;
55
+ declare function generate$2(targetSource: string | Buffer, { type, onlyLocales, filename, inSourceMap, locale, isGlobal, sourceMap, env, forceStringify, onError, strictMessage, escapeHtml, jit }: CodeGenOptions): CodeGenResult<JSONProgram>;
58
56
 
59
57
  /**
60
58
  * Code generator for i18n yaml resource
@@ -63,7 +61,7 @@ declare function generate$2(targetSource: string | Buffer, { type, onlyLocales,
63
61
  /**
64
62
  * @internal
65
63
  */
66
- declare function generate$1(targetSource: string | Buffer, { type, onlyLocales, useClassComponent, filename, inSourceMap, locale, isGlobal, sourceMap, env, forceStringify, onError, strictMessage, escapeHtml, jit }: CodeGenOptions): CodeGenResult<YAMLProgram>;
64
+ declare function generate$1(targetSource: string | Buffer, { type, onlyLocales, filename, inSourceMap, locale, isGlobal, sourceMap, env, forceStringify, onError, strictMessage, escapeHtml, jit }: CodeGenOptions): CodeGenResult<YAMLProgram>;
67
65
 
68
66
  /**
69
67
  * Code generator for i18n js resource
@@ -72,11 +70,11 @@ declare function generate$1(targetSource: string | Buffer, { type, onlyLocales,
72
70
  /**
73
71
  * @internal
74
72
  */
75
- declare function generate(targetSource: string | Buffer, { type, filename, inSourceMap, locale, isGlobal, sourceMap, env, forceStringify, onError, strictMessage, escapeHtml, useClassComponent, allowDynamic, jit }: CodeGenOptions): CodeGenResult<Node>;
73
+ declare function generate(targetSource: string | Buffer, { type, filename, inSourceMap, locale, isGlobal, sourceMap, env, forceStringify, onError, strictMessage, escapeHtml, allowDynamic, jit }: CodeGenOptions): CodeGenResult<Node>;
76
74
 
77
75
  type InstalledPackage = 'vue-i18n' | 'petite-vue-i18n';
78
76
  declare function checkInstallPackage(pkg: string, debug: Function): InstalledPackage;
79
- type VueI18nVersion = '8' | '9' | 'unknown' | '';
80
- declare function getVueI18nVersion(debug: Function): VueI18nVersion;
77
+ type VueI18nVersion = '9' | '10' | 'unknown' | '';
78
+ declare function getVueI18nVersion(debug: Function, pkg?: string): VueI18nVersion;
81
79
 
82
80
  export { type CodeGenOptions, type CodeGenResult, type DevEnv, type InstalledPackage, checkInstallPackage, generate$2 as generateJSON, generate as generateJavaScript, generate$1 as generateYAML, getVueI18nVersion };
package/lib/index.d.ts CHANGED
@@ -16,7 +16,6 @@ type DevEnv = 'development' | 'production';
16
16
  interface CodeGenOptions {
17
17
  type?: 'plain' | 'sfc' | 'bare';
18
18
  legacy?: boolean;
19
- vueVersion?: 'v2.6' | 'v2.7';
20
19
  bridge?: boolean;
21
20
  exportESM?: boolean;
22
21
  onlyLocales?: string[];
@@ -28,7 +27,6 @@ interface CodeGenOptions {
28
27
  locale?: string;
29
28
  env?: DevEnv;
30
29
  forceStringify?: boolean;
31
- useClassComponent?: boolean;
32
30
  allowDynamic?: boolean;
33
31
  strictMessage?: boolean;
34
32
  escapeHtml?: boolean;
@@ -54,7 +52,7 @@ interface CodeGenResult<ASTNode, CodeGenError extends Error = Error> {
54
52
  * Code / AST generator for i18n json/json5 resource
55
53
  */
56
54
 
57
- declare function generate$2(targetSource: string | Buffer, { type, onlyLocales, filename, inSourceMap, locale, isGlobal, sourceMap, env, forceStringify, onError, strictMessage, escapeHtml, useClassComponent, jit }: CodeGenOptions): CodeGenResult<JSONProgram>;
55
+ declare function generate$2(targetSource: string | Buffer, { type, onlyLocales, filename, inSourceMap, locale, isGlobal, sourceMap, env, forceStringify, onError, strictMessage, escapeHtml, jit }: CodeGenOptions): CodeGenResult<JSONProgram>;
58
56
 
59
57
  /**
60
58
  * Code generator for i18n yaml resource
@@ -63,7 +61,7 @@ declare function generate$2(targetSource: string | Buffer, { type, onlyLocales,
63
61
  /**
64
62
  * @internal
65
63
  */
66
- declare function generate$1(targetSource: string | Buffer, { type, onlyLocales, useClassComponent, filename, inSourceMap, locale, isGlobal, sourceMap, env, forceStringify, onError, strictMessage, escapeHtml, jit }: CodeGenOptions): CodeGenResult<YAMLProgram>;
64
+ declare function generate$1(targetSource: string | Buffer, { type, onlyLocales, filename, inSourceMap, locale, isGlobal, sourceMap, env, forceStringify, onError, strictMessage, escapeHtml, jit }: CodeGenOptions): CodeGenResult<YAMLProgram>;
67
65
 
68
66
  /**
69
67
  * Code generator for i18n js resource
@@ -72,11 +70,11 @@ declare function generate$1(targetSource: string | Buffer, { type, onlyLocales,
72
70
  /**
73
71
  * @internal
74
72
  */
75
- declare function generate(targetSource: string | Buffer, { type, filename, inSourceMap, locale, isGlobal, sourceMap, env, forceStringify, onError, strictMessage, escapeHtml, useClassComponent, allowDynamic, jit }: CodeGenOptions): CodeGenResult<Node>;
73
+ declare function generate(targetSource: string | Buffer, { type, filename, inSourceMap, locale, isGlobal, sourceMap, env, forceStringify, onError, strictMessage, escapeHtml, allowDynamic, jit }: CodeGenOptions): CodeGenResult<Node>;
76
74
 
77
75
  type InstalledPackage = 'vue-i18n' | 'petite-vue-i18n';
78
76
  declare function checkInstallPackage(pkg: string, debug: Function): InstalledPackage;
79
- type VueI18nVersion = '8' | '9' | 'unknown' | '';
80
- declare function getVueI18nVersion(debug: Function): VueI18nVersion;
77
+ type VueI18nVersion = '9' | '10' | 'unknown' | '';
78
+ declare function getVueI18nVersion(debug: Function, pkg?: string): VueI18nVersion;
81
79
 
82
80
  export { type CodeGenOptions, type CodeGenResult, type DevEnv, type InstalledPackage, checkInstallPackage, generate$2 as generateJSON, generate as generateJavaScript, generate$1 as generateYAML, getVueI18nVersion };
package/lib/index.mjs CHANGED
@@ -279,7 +279,6 @@ function generate$2(targetSource, {
279
279
  onError = void 0,
280
280
  strictMessage = true,
281
281
  escapeHtml = false,
282
- useClassComponent = false,
283
282
  jit = false
284
283
  }) {
285
284
  let value = Buffer.isBuffer(targetSource) ? targetSource.toString() : targetSource;
@@ -296,10 +295,8 @@ function generate$2(targetSource, {
296
295
  onError,
297
296
  strictMessage,
298
297
  escapeHtml,
299
- useClassComponent,
300
298
  jit
301
299
  };
302
- const generator = createCodeGenerator(options);
303
300
  let ast = parseJSON(value, { filePath: filename });
304
301
  if (!locale && type === "sfc" && onlyLocales?.length) {
305
302
  const messages = getStaticJSONValue(ast);
@@ -311,6 +308,13 @@ function generate$2(targetSource, {
311
308
  );
312
309
  ast = parseJSON(value, { filePath: filename });
313
310
  }
311
+ if (locale && onlyLocales?.length && !onlyLocales.includes(locale)) {
312
+ value = JSON.stringify({});
313
+ ast = parseJSON(value, { filePath: filename });
314
+ options.locale = "";
315
+ options.source = void 0;
316
+ }
317
+ const generator = createCodeGenerator(options);
314
318
  const codeMaps = _generate$2(generator, ast, options);
315
319
  const { code, map } = generator.context();
316
320
  const newMap = map && !jit ? mapLinesColumns(map.toJSON(), codeMaps, inSourceMap) || null : null;
@@ -326,7 +330,7 @@ function _generate$2(generator, node, options = {}) {
326
330
  const itemsCountStack = [];
327
331
  const { forceStringify } = generator.context();
328
332
  const codeMaps = /* @__PURE__ */ new Map();
329
- const { type, sourceMap, isGlobal, locale, useClassComponent, jit } = options;
333
+ const { type, sourceMap, isGlobal, locale, jit } = options;
330
334
  const codegenFn = jit ? generateResourceAst : generateMessageFunction;
331
335
  const componentNamespace = "_Component";
332
336
  traverseNodes(node, {
@@ -341,8 +345,10 @@ function _generate$2(generator, node, options = {}) {
341
345
  const exportSyntax = "export default";
342
346
  generator.push(`${exportSyntax} function (Component) {`);
343
347
  generator.indent();
344
- const componentVariable = useClassComponent ? `Component.__o || Component.__vccOpts || Component` : `Component`;
345
- generator.pushline(`const ${componentNamespace} = ${componentVariable}`);
348
+ const componentVariable = `Component`;
349
+ generator.pushline(
350
+ `const ${componentNamespace} = ${componentVariable}`
351
+ );
346
352
  generator.pushline(
347
353
  `${componentNamespace}.${variableName} = ${componentNamespace}.${variableName} || []`
348
354
  );
@@ -501,7 +507,6 @@ function _generate$2(generator, node, options = {}) {
501
507
  function generate$1(targetSource, {
502
508
  type = "plain",
503
509
  onlyLocales = [],
504
- useClassComponent = false,
505
510
  filename = "vue-i18n-loader.yaml",
506
511
  inSourceMap = void 0,
507
512
  locale = "",
@@ -528,10 +533,8 @@ function generate$1(targetSource, {
528
533
  onError,
529
534
  strictMessage,
530
535
  escapeHtml,
531
- useClassComponent,
532
536
  jit
533
537
  };
534
- const generator = createCodeGenerator(options);
535
538
  let ast = parseYAML(value, { filePath: filename });
536
539
  if (!locale && type === "sfc" && onlyLocales?.length) {
537
540
  const messages = getStaticYAMLValue(ast);
@@ -543,6 +546,13 @@ function generate$1(targetSource, {
543
546
  );
544
547
  ast = parseYAML(value, { filePath: filename });
545
548
  }
549
+ if (locale && onlyLocales?.length && !onlyLocales.includes(locale)) {
550
+ value = JSON.stringify({});
551
+ ast = parseYAML(value, { filePath: filename });
552
+ options.locale = "";
553
+ options.source = void 0;
554
+ }
555
+ const generator = createCodeGenerator(options);
546
556
  const codeMaps = _generate$1(generator, ast, options);
547
557
  const { code, map } = generator.context();
548
558
  const newMap = map ? mapLinesColumns(map.toJSON(), codeMaps, inSourceMap) || null : null;
@@ -558,7 +568,7 @@ function _generate$1(generator, node, options = {}) {
558
568
  const itemsCountStack = [];
559
569
  const { forceStringify } = generator.context();
560
570
  const codeMaps = /* @__PURE__ */ new Map();
561
- const { type, sourceMap, isGlobal, locale, useClassComponent, jit } = options;
571
+ const { type, sourceMap, isGlobal, locale, jit } = options;
562
572
  const codegenFn = jit ? generateResourceAst : generateMessageFunction;
563
573
  const componentNamespace = "_Component";
564
574
  traverseNodes$1(node, {
@@ -573,8 +583,10 @@ function _generate$1(generator, node, options = {}) {
573
583
  const exportSyntax = "export default";
574
584
  generator.push(`${exportSyntax} function (Component) {`);
575
585
  generator.indent();
576
- const componentVariable = useClassComponent ? `Component.__o || Component.__vccOpts || Component` : `Component`;
577
- generator.pushline(`const ${componentNamespace} = ${componentVariable}`);
586
+ const componentVariable = `Component`;
587
+ generator.pushline(
588
+ `const ${componentNamespace} = ${componentVariable}`
589
+ );
578
590
  generator.pushline(
579
591
  `${componentNamespace}.${variableName} = ${componentNamespace}.${variableName} || []`
580
592
  );
@@ -742,7 +754,6 @@ function generate(targetSource, {
742
754
  onError = void 0,
743
755
  strictMessage = true,
744
756
  escapeHtml = false,
745
- useClassComponent = false,
746
757
  allowDynamic = false,
747
758
  jit = false
748
759
  }) {
@@ -761,7 +772,6 @@ function generate(targetSource, {
761
772
  onError,
762
773
  strictMessage,
763
774
  escapeHtml,
764
- useClassComponent,
765
775
  jit
766
776
  };
767
777
  const generator = createCodeGenerator(options);
@@ -829,7 +839,7 @@ function _generate(generator, node, options = {}) {
829
839
  const skipStack = [];
830
840
  const { forceStringify } = generator.context();
831
841
  const codeMaps = /* @__PURE__ */ new Map();
832
- const { type, sourceMap, isGlobal, locale, useClassComponent, jit } = options;
842
+ const { type, sourceMap, isGlobal, locale, jit } = options;
833
843
  const codegenFn = jit ? generateResourceAst : generateMessageFunction;
834
844
  const componentNamespace = "_Component";
835
845
  walk(node, {
@@ -851,8 +861,10 @@ function _generate(generator, node, options = {}) {
851
861
  const exportSyntax = "export default";
852
862
  generator.push(`${exportSyntax} function (Component) {`);
853
863
  generator.indent();
854
- const componentVariable = useClassComponent ? `Component.__o || Component.__vccOpts || Component` : `Component`;
855
- generator.pushline(`const ${componentNamespace} = ${componentVariable}`);
864
+ const componentVariable = `Component`;
865
+ generator.pushline(
866
+ `const ${componentNamespace} = ${componentVariable}`
867
+ );
856
868
  generator.pushline(
857
869
  `${componentNamespace}.${variableName} = ${componentNamespace}.${variableName} || []`
858
870
  );
@@ -1087,17 +1099,17 @@ function checkInstallPackage(pkg, debug) {
1087
1099
  `${pkg} requires 'vue-i18n' or 'petite-vue-i18n' to be present in the dependency tree.`
1088
1100
  );
1089
1101
  }
1090
- function getVueI18nVersion(debug) {
1091
- const VueI18n = loadModule("vue-i18n", debug);
1102
+ function getVueI18nVersion(debug, pkg = "vue-i18n") {
1103
+ const VueI18n = loadModule(pkg, debug);
1092
1104
  if (VueI18n == null) {
1093
1105
  return "";
1094
1106
  }
1095
- if (VueI18n.version && VueI18n.version.startsWith("8.")) {
1096
- return "8";
1097
- }
1098
1107
  if (VueI18n.VERSION && VueI18n.VERSION.startsWith("9.")) {
1099
1108
  return "9";
1100
1109
  }
1110
+ if (VueI18n.VERSION && VueI18n.VERSION.startsWith("10.")) {
1111
+ return "10";
1112
+ }
1101
1113
  return "unknown";
1102
1114
  }
1103
1115
  function loadModule(moduleName, debug) {
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": "8.0.0",
4
+ "version": "9.0.0-beta.0",
5
5
  "author": {
6
6
  "name": "kazuya kawaguchi",
7
7
  "email": "kawakazu80@gmail.com"
@@ -18,8 +18,8 @@
18
18
  }
19
19
  },
20
20
  "dependencies": {
21
- "@intlify/message-compiler": "^9.4.0",
22
- "@intlify/shared": "^9.4.0",
21
+ "@intlify/message-compiler": "next",
22
+ "@intlify/shared": "next",
23
23
  "acorn": "^8.8.2",
24
24
  "escodegen": "^2.1.0",
25
25
  "estree-walker": "^2.0.2",
@@ -34,7 +34,7 @@
34
34
  "unbuild": "^2.0.0"
35
35
  },
36
36
  "engines": {
37
- "node": ">= 14.16"
37
+ "node": ">= 18"
38
38
  },
39
39
  "files": [
40
40
  "lib",