@intlify/unplugin-vue-i18n 1.5.0 → 2.0.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/README.md CHANGED
@@ -281,13 +281,13 @@ This plugin will automatically select and bundle `petite-vue-i18n` build accordi
281
281
 
282
282
  If nothing is specified for this option, i.e. `undefined`, nothing is done to the resource in the above format.
283
283
 
284
- > ⚠️ NOTE:
284
+ > ⚠️ NOTE:
285
285
  `json` resources matches this option, it will be handled **before the internal json plugin of bundler, and will not be processed afterwards**, else the option doesn't match, the bundler side will handle.
286
286
 
287
- > ⚠️ NOTE:
287
+ > ⚠️ NOTE:
288
288
  `yaml` resources don't support multi documentation with `|`, alias with `&` and `*`, tags with `! `, `@`, etc. Only simple data structures.
289
289
 
290
- > ⚠️ NOTE:
290
+ > ⚠️ NOTE:
291
291
  `js` and `ts` resources are set **simple export (`export default`) as locale messages object, as default**.
292
292
 
293
293
  ```js
@@ -299,7 +299,7 @@ This plugin will automatically select and bundle `petite-vue-i18n` build accordi
299
299
 
300
300
  If you need to use programmatically dynamic resource construction, you would be enable `allowDynamic` option. about details, see the section.
301
301
 
302
- > ⚠️ NOTE:
302
+ > ⚠️ NOTE:
303
303
  If you use the `js` and `ts` resources formats, set the paths, so your application code is not targeted. We recommend that resources be isolated from the application code.
304
304
 
305
305
 
@@ -354,12 +354,12 @@ This plugin will automatically select and bundle `petite-vue-i18n` build accordi
354
354
 
355
355
  Whether locale mesages should be compiled by JIT (Just in Time) compilation with vue-i18n's message compiler.
356
356
 
357
- > ⚠️ NOTE:
357
+ > ⚠️ NOTE:
358
358
  This option works with vue-i18n v9.3 and later.
359
359
 
360
360
  JIT compilation has been supported since vue-i18n v9.3. This means that since v9 was released until now, the message compiler compiles to executable JavaScript code, however it did not work in the CSP environment. Also, since this was an AOT (Ahead of Time) compilation, it was not possible to dynamically retrieve locale messages from the back-end Database and compose locale mesages with programatic.
361
361
 
362
- > ⚠️ NOTE:
362
+ > ⚠️ NOTE:
363
363
  Enabling JIT compilation causes the message compiler to generate AST objects for locale mesages instead of JavaScript code. If you pre-compile locale messages with a tool such as the [Intlify CLI](https://github.com/intlify/cli) and import them dynamically, you need to rebuild that resource.
364
364
 
365
365
  About JIT compilation, See [here](https://vue-i18n.intlify.dev/guide/advanced/optimization.html#jit-compilation)
@@ -373,10 +373,10 @@ Whether to tree-shake message compiler when we will be bundling.
373
373
 
374
374
  If do you will use this option, you need to enable `jitCompilation` option.
375
375
 
376
- > ⚠️ NOTE:
376
+ > ⚠️ NOTE:
377
377
  This option works with vue-i18n v9.3 and later.
378
378
 
379
- > ⚠️ NOTE:
379
+ > ⚠️ NOTE:
380
380
  If you enable this option, **you should check resources in your application are pre-compiled with this plugin.** If you will be loading resources dynamically from the back-end via the API, enabling this option do not work because there is not message compiler.
381
381
 
382
382
  ### `ssr`
@@ -386,7 +386,7 @@ If you enable this option, **you should check resources in your application are
386
386
 
387
387
  Whether to bundle vue-i18n module for SSR at build time
388
388
 
389
- > ⚠️ NOTE:
389
+ > ⚠️ NOTE:
390
390
  This option works with vue-i18n v9.4 and later.
391
391
 
392
392
  ### `runtimeOnly`
@@ -395,7 +395,7 @@ If you enable this option, **you should check resources in your application are
395
395
  - **Default:** `true`
396
396
 
397
397
  Whether or not to automatically use Vue I18n **runtime-only** in production build, set `vue-i18n.runtime.esm-bundler.js` in the `vue-i18n` field of bundler config, the below:
398
-
398
+
399
399
  ```
400
400
  - vite config: `resolve.alias`
401
401
  - webpack config: `resolve.alias`
@@ -547,6 +547,24 @@ If you enable this option, **you should check resources in your application are
547
547
 
548
548
  > ⚠️ Note that if you set `bridge: true`, the bundle size will increase. It is recommended to disable this mode after the migration from vue-i18n@v8.26 to vue-i18n@v9.x is completed.
549
549
 
550
+ ### `legacy`
551
+
552
+ - **Type:** `boolean`
553
+ - **Default:** `false`
554
+
555
+ This option supports Vue I18n v8.x compatibility for resources in i18n custom blocks.
556
+
557
+ > ⚠️ To work for Vue 2.7, the value of `vueVersion` must be set to `'v2.7'`.
558
+
559
+ ### `vueVersion`
560
+
561
+ - **Type:** `string`
562
+ - **Default:** `undefined`
563
+
564
+ The version of Vue that will be used by Vue I18n. This option is enabled when the `legacy` option is `true`.
565
+
566
+ Available values are `'v2.6'` and `'v2.7'`.
567
+
550
568
  ### `esm`
551
569
 
552
570
  - **Type:** `boolean`
package/lib/index.cjs CHANGED
@@ -98,7 +98,6 @@ function raiseError(message) {
98
98
  }
99
99
 
100
100
  const INTLIFY_BUNDLE_IMPORT_ID = "@intlify/unplugin-vue-i18n/messages";
101
- const INTLIFY_BUNDLE_IMPORT_DEPRECTED_ID = "@intlify/vite-plugin-vue-i18n/messages";
102
101
  const VIRTUAL_PREFIX = "\0";
103
102
  const debug = createDebug__default("unplugin-vue-i18n");
104
103
  const installedPkg = bundleUtils.checkInstallPackage("@intlify/unplugin-vue-i18n", debug);
@@ -131,6 +130,9 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
131
130
  const useClassComponent = !!options.useClassComponent;
132
131
  const bridge = !!options.bridge;
133
132
  debug("bridge", bridge);
133
+ const legacy = !!options.legacy;
134
+ debug("legacy", legacy);
135
+ const vueVersion = shared.isString(options.vueVersion) ? options.vueVersion : void 0;
134
136
  const runtimeOnly = shared.isBoolean(options.runtimeOnly) ? options.runtimeOnly : true;
135
137
  debug("runtimeOnly", runtimeOnly);
136
138
  const jitCompilation = !!options.jitCompilation;
@@ -307,6 +309,8 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
307
309
  strictMessage,
308
310
  escapeHtml,
309
311
  bridge,
312
+ legacy,
313
+ vueVersion,
310
314
  jit: jitCompilation,
311
315
  onlyLocales,
312
316
  exportESM: esm,
@@ -405,12 +409,6 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
405
409
  },
406
410
  resolveId(id, importer) {
407
411
  debug("resolveId", id, importer);
408
- if (id === INTLIFY_BUNDLE_IMPORT_DEPRECTED_ID) {
409
- warn(
410
- `deprected '${INTLIFY_BUNDLE_IMPORT_DEPRECTED_ID}', you should switch to '${INTLIFY_BUNDLE_IMPORT_ID}'`
411
- );
412
- return asVirtualId(id, meta.framework);
413
- }
414
412
  if (id === INTLIFY_BUNDLE_IMPORT_ID) {
415
413
  return asVirtualId(id, meta.framework);
416
414
  }
@@ -419,9 +417,7 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
419
417
  async load(id) {
420
418
  debug("load", id);
421
419
  const { query } = parseVueRequest(id);
422
- if ([INTLIFY_BUNDLE_IMPORT_DEPRECTED_ID, INTLIFY_BUNDLE_IMPORT_ID].includes(
423
- getVirtualId(id, meta.framework)
424
- ) && include) {
420
+ if (INTLIFY_BUNDLE_IMPORT_ID === getVirtualId(id, meta.framework) && include) {
425
421
  let resourcePaths = [];
426
422
  const includePaths = shared.isArray(include) ? include : [include];
427
423
  for (const inc of includePaths) {
@@ -455,7 +451,7 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
455
451
  return true;
456
452
  } else {
457
453
  const { filename } = parseVueRequest(id);
458
- return filename.endsWith("vue") || filename.endsWith(INTLIFY_BUNDLE_IMPORT_ID) || filename.endsWith(INTLIFY_BUNDLE_IMPORT_DEPRECTED_ID) || /\.(json5?|ya?ml)$/.test(filename) && filter(filename);
454
+ return filename.endsWith("vue") || filename.endsWith(INTLIFY_BUNDLE_IMPORT_ID) || /\.(json5?|ya?ml)$/.test(filename) && filter(filename);
459
455
  }
460
456
  },
461
457
  async transform(code, id) {
@@ -522,6 +518,8 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
522
518
  isGlobal: globalSFCScope,
523
519
  useClassComponent,
524
520
  bridge,
521
+ legacy,
522
+ vueVersion,
525
523
  jit: jitCompilation,
526
524
  strictMessage,
527
525
  escapeHtml,
@@ -690,6 +688,8 @@ function getOptions(filename, isProduction, query, sourceMap, {
690
688
  forceStringify = false,
691
689
  isGlobal = false,
692
690
  bridge = false,
691
+ legacy = false,
692
+ vueVersion = "v2.6",
693
693
  onlyLocales = [],
694
694
  exportESM = true,
695
695
  useClassComponent = false,
@@ -709,6 +709,8 @@ function getOptions(filename, isProduction, query, sourceMap, {
709
709
  strictMessage,
710
710
  escapeHtml,
711
711
  bridge,
712
+ legacy,
713
+ vueVersion,
712
714
  jit,
713
715
  onlyLocales,
714
716
  exportESM,
package/lib/index.d.cts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as _unplugin from 'unplugin';
2
2
  import { PluginOptions } from './types.cjs';
3
3
  export { SFCLangFormat } from './types.cjs';
4
+ import '@intlify/bundle-utils';
4
5
 
5
6
  declare const unplugin: _unplugin.UnpluginInstance<PluginOptions, boolean>;
6
7
 
package/lib/index.d.mts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as _unplugin from 'unplugin';
2
2
  import { PluginOptions } from './types.mjs';
3
3
  export { SFCLangFormat } from './types.mjs';
4
+ import '@intlify/bundle-utils';
4
5
 
5
6
  declare const unplugin: _unplugin.UnpluginInstance<PluginOptions, boolean>;
6
7
 
package/lib/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as _unplugin from 'unplugin';
2
2
  import { PluginOptions } from './types.js';
3
3
  export { SFCLangFormat } from './types.js';
4
+ import '@intlify/bundle-utils';
4
5
 
5
6
  declare const unplugin: _unplugin.UnpluginInstance<PluginOptions, boolean>;
6
7
 
package/lib/index.mjs CHANGED
@@ -86,7 +86,6 @@ function raiseError(message) {
86
86
  }
87
87
 
88
88
  const INTLIFY_BUNDLE_IMPORT_ID = "@intlify/unplugin-vue-i18n/messages";
89
- const INTLIFY_BUNDLE_IMPORT_DEPRECTED_ID = "@intlify/vite-plugin-vue-i18n/messages";
90
89
  const VIRTUAL_PREFIX = "\0";
91
90
  const debug = createDebug("unplugin-vue-i18n");
92
91
  const installedPkg = checkInstallPackage("@intlify/unplugin-vue-i18n", debug);
@@ -119,6 +118,9 @@ const unplugin = createUnplugin((options = {}, meta) => {
119
118
  const useClassComponent = !!options.useClassComponent;
120
119
  const bridge = !!options.bridge;
121
120
  debug("bridge", bridge);
121
+ const legacy = !!options.legacy;
122
+ debug("legacy", legacy);
123
+ const vueVersion = isString(options.vueVersion) ? options.vueVersion : void 0;
122
124
  const runtimeOnly = isBoolean(options.runtimeOnly) ? options.runtimeOnly : true;
123
125
  debug("runtimeOnly", runtimeOnly);
124
126
  const jitCompilation = !!options.jitCompilation;
@@ -295,6 +297,8 @@ const unplugin = createUnplugin((options = {}, meta) => {
295
297
  strictMessage,
296
298
  escapeHtml,
297
299
  bridge,
300
+ legacy,
301
+ vueVersion,
298
302
  jit: jitCompilation,
299
303
  onlyLocales,
300
304
  exportESM: esm,
@@ -393,12 +397,6 @@ const unplugin = createUnplugin((options = {}, meta) => {
393
397
  },
394
398
  resolveId(id, importer) {
395
399
  debug("resolveId", id, importer);
396
- if (id === INTLIFY_BUNDLE_IMPORT_DEPRECTED_ID) {
397
- warn(
398
- `deprected '${INTLIFY_BUNDLE_IMPORT_DEPRECTED_ID}', you should switch to '${INTLIFY_BUNDLE_IMPORT_ID}'`
399
- );
400
- return asVirtualId(id, meta.framework);
401
- }
402
400
  if (id === INTLIFY_BUNDLE_IMPORT_ID) {
403
401
  return asVirtualId(id, meta.framework);
404
402
  }
@@ -407,9 +405,7 @@ const unplugin = createUnplugin((options = {}, meta) => {
407
405
  async load(id) {
408
406
  debug("load", id);
409
407
  const { query } = parseVueRequest(id);
410
- if ([INTLIFY_BUNDLE_IMPORT_DEPRECTED_ID, INTLIFY_BUNDLE_IMPORT_ID].includes(
411
- getVirtualId(id, meta.framework)
412
- ) && include) {
408
+ if (INTLIFY_BUNDLE_IMPORT_ID === getVirtualId(id, meta.framework) && include) {
413
409
  let resourcePaths = [];
414
410
  const includePaths = isArray(include) ? include : [include];
415
411
  for (const inc of includePaths) {
@@ -443,7 +439,7 @@ const unplugin = createUnplugin((options = {}, meta) => {
443
439
  return true;
444
440
  } else {
445
441
  const { filename } = parseVueRequest(id);
446
- return filename.endsWith("vue") || filename.endsWith(INTLIFY_BUNDLE_IMPORT_ID) || filename.endsWith(INTLIFY_BUNDLE_IMPORT_DEPRECTED_ID) || /\.(json5?|ya?ml)$/.test(filename) && filter(filename);
442
+ return filename.endsWith("vue") || filename.endsWith(INTLIFY_BUNDLE_IMPORT_ID) || /\.(json5?|ya?ml)$/.test(filename) && filter(filename);
447
443
  }
448
444
  },
449
445
  async transform(code, id) {
@@ -510,6 +506,8 @@ const unplugin = createUnplugin((options = {}, meta) => {
510
506
  isGlobal: globalSFCScope,
511
507
  useClassComponent,
512
508
  bridge,
509
+ legacy,
510
+ vueVersion,
513
511
  jit: jitCompilation,
514
512
  strictMessage,
515
513
  escapeHtml,
@@ -678,6 +676,8 @@ function getOptions(filename, isProduction, query, sourceMap, {
678
676
  forceStringify = false,
679
677
  isGlobal = false,
680
678
  bridge = false,
679
+ legacy = false,
680
+ vueVersion = "v2.6",
681
681
  onlyLocales = [],
682
682
  exportESM = true,
683
683
  useClassComponent = false,
@@ -697,6 +697,8 @@ function getOptions(filename, isProduction, query, sourceMap, {
697
697
  strictMessage,
698
698
  escapeHtml,
699
699
  bridge,
700
+ legacy,
701
+ vueVersion,
700
702
  jit,
701
703
  onlyLocales,
702
704
  exportESM,
package/lib/types.d.cts CHANGED
@@ -1,3 +1,5 @@
1
+ import { CodeGenOptions } from '@intlify/bundle-utils';
2
+
1
3
  type SFCLangFormat = 'json' | 'json5' | 'yml' | 'yaml';
2
4
  interface PluginOptions {
3
5
  include?: string | string[];
@@ -14,6 +16,8 @@ interface PluginOptions {
14
16
  defaultSFCLang?: SFCLangFormat;
15
17
  globalSFCScope?: boolean;
16
18
  bridge?: boolean;
19
+ legacy?: boolean;
20
+ vueVersion?: CodeGenOptions['vueVersion'];
17
21
  useClassComponent?: boolean;
18
22
  useVueI18nImportName?: boolean;
19
23
  strictMessage?: boolean;
package/lib/types.d.mts CHANGED
@@ -1,3 +1,5 @@
1
+ import { CodeGenOptions } from '@intlify/bundle-utils';
2
+
1
3
  type SFCLangFormat = 'json' | 'json5' | 'yml' | 'yaml';
2
4
  interface PluginOptions {
3
5
  include?: string | string[];
@@ -14,6 +16,8 @@ interface PluginOptions {
14
16
  defaultSFCLang?: SFCLangFormat;
15
17
  globalSFCScope?: boolean;
16
18
  bridge?: boolean;
19
+ legacy?: boolean;
20
+ vueVersion?: CodeGenOptions['vueVersion'];
17
21
  useClassComponent?: boolean;
18
22
  useVueI18nImportName?: boolean;
19
23
  strictMessage?: boolean;
package/lib/types.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { CodeGenOptions } from '@intlify/bundle-utils';
2
+
1
3
  type SFCLangFormat = 'json' | 'json5' | 'yml' | 'yaml';
2
4
  interface PluginOptions {
3
5
  include?: string | string[];
@@ -14,6 +16,8 @@ interface PluginOptions {
14
16
  defaultSFCLang?: SFCLangFormat;
15
17
  globalSFCScope?: boolean;
16
18
  bridge?: boolean;
19
+ legacy?: boolean;
20
+ vueVersion?: CodeGenOptions['vueVersion'];
17
21
  useClassComponent?: boolean;
18
22
  useVueI18nImportName?: boolean;
19
23
  strictMessage?: boolean;
package/lib/vite.d.cts CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as vite from 'vite';
2
2
  import { PluginOptions } from './types.cjs';
3
+ import '@intlify/bundle-utils';
3
4
 
4
5
  declare const _default: (options: PluginOptions) => vite.Plugin | vite.Plugin[];
5
6
 
package/lib/vite.d.mts CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as vite from 'vite';
2
2
  import { PluginOptions } from './types.mjs';
3
+ import '@intlify/bundle-utils';
3
4
 
4
5
  declare const _default: (options: PluginOptions) => vite.Plugin | vite.Plugin[];
5
6
 
package/lib/vite.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as vite from 'vite';
2
2
  import { PluginOptions } from './types.js';
3
+ import '@intlify/bundle-utils';
3
4
 
4
5
  declare const _default: (options: PluginOptions) => vite.Plugin | vite.Plugin[];
5
6
 
package/lib/webpack.d.cts CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as webpack from 'webpack';
2
2
  import { PluginOptions } from './types.cjs';
3
+ import '@intlify/bundle-utils';
3
4
 
4
5
  declare const _default: (options: PluginOptions) => webpack.WebpackPluginInstance;
5
6
 
package/lib/webpack.d.mts CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as webpack from 'webpack';
2
2
  import { PluginOptions } from './types.mjs';
3
+ import '@intlify/bundle-utils';
3
4
 
4
5
  declare const _default: (options: PluginOptions) => webpack.WebpackPluginInstance;
5
6
 
package/lib/webpack.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as webpack from 'webpack';
2
2
  import { PluginOptions } from './types.js';
3
+ import '@intlify/bundle-utils';
3
4
 
4
5
  declare const _default: (options: PluginOptions) => webpack.WebpackPluginInstance;
5
6
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlify/unplugin-vue-i18n",
3
- "version": "1.5.0",
3
+ "version": "2.0.0",
4
4
  "description": "unplugin for Vue I18n",
5
5
  "author": {
6
6
  "name": "kazuya kawaguchi",