@intlify/unplugin-vue-i18n 1.6.0 → 3.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
+ > [!WARNING]
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
+ > [!WARNING]
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
+ > [!WARNING]
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
+ > [!WARNING]
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
 
@@ -350,16 +350,19 @@ This plugin will automatically select and bundle `petite-vue-i18n` build accordi
350
350
  ### `jitCompilation`
351
351
 
352
352
  - **Type:** `boolean`
353
- - **Default:** `false`
353
+ - **Default:** `true`
354
+
355
+ > [!IMPORTANT]
356
+ 'jitCompilation' option now defaults to `true` from 3.0.
354
357
 
355
358
  Whether locale mesages should be compiled by JIT (Just in Time) compilation with vue-i18n's message compiler.
356
359
 
357
- > ⚠️ NOTE:
360
+ > [!NOTE]
358
361
  This option works with vue-i18n v9.3 and later.
359
362
 
360
363
  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
364
 
362
- > ⚠️ NOTE:
365
+ > [!WARNING]
363
366
  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
367
 
365
368
  About JIT compilation, See [here](https://vue-i18n.intlify.dev/guide/advanced/optimization.html#jit-compilation)
@@ -373,11 +376,11 @@ Whether to tree-shake message compiler when we will be bundling.
373
376
 
374
377
  If do you will use this option, you need to enable `jitCompilation` option.
375
378
 
376
- > ⚠️ NOTE:
377
- This option works with vue-i18n v9.3 and later.
379
+ > [!NOTE]
380
+ This option works with vue-i18n v9.3 and later.
378
381
 
379
- > ⚠️ NOTE:
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.
382
+ > [!WARNING]
383
+ 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
384
 
382
385
  ### `ssr`
383
386
 
@@ -386,7 +389,7 @@ If you enable this option, **you should check resources in your application are
386
389
 
387
390
  Whether to bundle vue-i18n module for SSR at build time
388
391
 
389
- > ⚠️ NOTE:
392
+ > [!NOTE]
390
393
  This option works with vue-i18n v9.4 and later.
391
394
 
392
395
  ### `runtimeOnly`
@@ -541,26 +544,37 @@ If you enable this option, **you should check resources in your application are
541
544
  - **Type:** `boolean`
542
545
  - **Default:** `false`
543
546
 
547
+ > [!WARNING]
548
+ 'bridge' option is deprecated, sinece Vue 2 was EOL on 2023. that option will be removed in 4.0.`
549
+
544
550
  The mode to birdge the i18n custom block to work in both vue-i18n@v8.x and vue-i18n@v9.x environments.
545
551
 
546
552
  To support in a smooth transition from vue-i18n@v8.x to vue-i18n@v9.x, we provide a mode that bundles the i18n custom block to be available in either version.
547
553
 
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.
554
+ > [!WARNING]
555
+ 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
556
 
550
557
  ### `legacy`
551
558
 
552
559
  - **Type:** `boolean`
553
560
  - **Default:** `false`
554
561
 
562
+ > [!WARNING]
563
+ 'legacy' option is deprecated, sinece Vue 2 was EOL on 2023. that option will be removed in 4.0.`
564
+
555
565
  This option supports Vue I18n v8.x compatibility for resources in i18n custom blocks.
556
566
 
557
- > ⚠️ To work for Vue 2.7, the value of `vueVersion` must be set to `'v2.7'`.
567
+ > [!NOTE]
568
+ To work for Vue 2.7, the value of `vueVersion` must be set to `'v2.7'`.
558
569
 
559
570
  ### `vueVersion`
560
571
 
561
572
  - **Type:** `string`
562
573
  - **Default:** `undefined`
563
574
 
575
+ > [!WARNING]
576
+ 'vueVersion' option is deprecated, sinece Vue 2 was EOL on 2023. that option will be removed in 4.0.`
577
+
564
578
  The version of Vue that will be used by Vue I18n. This option is enabled when the `legacy` option is `true`.
565
579
 
566
580
  Available values are `'v2.6'` and `'v2.7'`.
package/lib/index.cjs CHANGED
@@ -98,12 +98,14 @@ 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);
105
104
  const installedVueI18nBridge = bundleUtils.checkVueI18nBridgeInstallPackage(debug);
106
105
  const vueI18nVersion = bundleUtils.getVueI18nVersion(debug);
106
+ if (vueI18nVersion === "8") {
107
+ warn(`vue-i18n@8 is not supported, since sinece Vue 2 was EOL on 2023.`);
108
+ }
107
109
  const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
108
110
  debug("plugin options:", options, meta.framework);
109
111
  if (!["vite", "webpack"].includes(meta.framework)) {
@@ -131,12 +133,27 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
131
133
  const useClassComponent = !!options.useClassComponent;
132
134
  const bridge = !!options.bridge;
133
135
  debug("bridge", bridge);
136
+ if (bridge) {
137
+ warn(
138
+ `'bridge' option is deprecated, sinece Vue 2 was EOL on 2023. that option will be removed in 4.0.`
139
+ );
140
+ }
134
141
  const legacy = !!options.legacy;
135
142
  debug("legacy", legacy);
143
+ if (legacy) {
144
+ warn(
145
+ `'legacy' option is deprecated, sinece Vue 2 was EOL on 2023. that option will be removed in 4.0.`
146
+ );
147
+ }
136
148
  const vueVersion = shared.isString(options.vueVersion) ? options.vueVersion : void 0;
149
+ if (!vueVersion) {
150
+ warn(
151
+ `'vueVersion' option is deprecated, sinece Vue 2 was EOL on 2023. that option will be removed in 4.0.`
152
+ );
153
+ }
137
154
  const runtimeOnly = shared.isBoolean(options.runtimeOnly) ? options.runtimeOnly : true;
138
155
  debug("runtimeOnly", runtimeOnly);
139
- const jitCompilation = !!options.jitCompilation;
156
+ const jitCompilation = shared.isBoolean(options.jitCompilation) ? options.jitCompilation : true;
140
157
  debug("jitCompilation", jitCompilation);
141
158
  const dropMessageCompiler = jitCompilation ? !!options.dropMessageCompiler : false;
142
159
  debug("dropMessageCompiler", dropMessageCompiler);
@@ -410,12 +427,6 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
410
427
  },
411
428
  resolveId(id, importer) {
412
429
  debug("resolveId", id, importer);
413
- if (id === INTLIFY_BUNDLE_IMPORT_DEPRECTED_ID) {
414
- warn(
415
- `deprected '${INTLIFY_BUNDLE_IMPORT_DEPRECTED_ID}', you should switch to '${INTLIFY_BUNDLE_IMPORT_ID}'`
416
- );
417
- return asVirtualId(id, meta.framework);
418
- }
419
430
  if (id === INTLIFY_BUNDLE_IMPORT_ID) {
420
431
  return asVirtualId(id, meta.framework);
421
432
  }
@@ -424,9 +435,7 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
424
435
  async load(id) {
425
436
  debug("load", id);
426
437
  const { query } = parseVueRequest(id);
427
- if ([INTLIFY_BUNDLE_IMPORT_DEPRECTED_ID, INTLIFY_BUNDLE_IMPORT_ID].includes(
428
- getVirtualId(id, meta.framework)
429
- ) && include) {
438
+ if (INTLIFY_BUNDLE_IMPORT_ID === getVirtualId(id, meta.framework) && include) {
430
439
  let resourcePaths = [];
431
440
  const includePaths = shared.isArray(include) ? include : [include];
432
441
  for (const inc of includePaths) {
@@ -460,7 +469,7 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
460
469
  return true;
461
470
  } else {
462
471
  const { filename } = parseVueRequest(id);
463
- return filename.endsWith("vue") || filename.endsWith(INTLIFY_BUNDLE_IMPORT_ID) || filename.endsWith(INTLIFY_BUNDLE_IMPORT_DEPRECTED_ID) || /\.(json5?|ya?ml)$/.test(filename) && filter(filename);
472
+ return filename.endsWith("vue") || filename.endsWith(INTLIFY_BUNDLE_IMPORT_ID) || /\.(json5?|ya?ml)$/.test(filename) && filter(filename);
464
473
  }
465
474
  },
466
475
  async transform(code, id) {
package/lib/index.mjs CHANGED
@@ -86,12 +86,14 @@ 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);
93
92
  const installedVueI18nBridge = checkVueI18nBridgeInstallPackage(debug);
94
93
  const vueI18nVersion = getVueI18nVersion(debug);
94
+ if (vueI18nVersion === "8") {
95
+ warn(`vue-i18n@8 is not supported, since sinece Vue 2 was EOL on 2023.`);
96
+ }
95
97
  const unplugin = createUnplugin((options = {}, meta) => {
96
98
  debug("plugin options:", options, meta.framework);
97
99
  if (!["vite", "webpack"].includes(meta.framework)) {
@@ -119,12 +121,27 @@ const unplugin = createUnplugin((options = {}, meta) => {
119
121
  const useClassComponent = !!options.useClassComponent;
120
122
  const bridge = !!options.bridge;
121
123
  debug("bridge", bridge);
124
+ if (bridge) {
125
+ warn(
126
+ `'bridge' option is deprecated, sinece Vue 2 was EOL on 2023. that option will be removed in 4.0.`
127
+ );
128
+ }
122
129
  const legacy = !!options.legacy;
123
130
  debug("legacy", legacy);
131
+ if (legacy) {
132
+ warn(
133
+ `'legacy' option is deprecated, sinece Vue 2 was EOL on 2023. that option will be removed in 4.0.`
134
+ );
135
+ }
124
136
  const vueVersion = isString(options.vueVersion) ? options.vueVersion : void 0;
137
+ if (!vueVersion) {
138
+ warn(
139
+ `'vueVersion' option is deprecated, sinece Vue 2 was EOL on 2023. that option will be removed in 4.0.`
140
+ );
141
+ }
125
142
  const runtimeOnly = isBoolean(options.runtimeOnly) ? options.runtimeOnly : true;
126
143
  debug("runtimeOnly", runtimeOnly);
127
- const jitCompilation = !!options.jitCompilation;
144
+ const jitCompilation = isBoolean(options.jitCompilation) ? options.jitCompilation : true;
128
145
  debug("jitCompilation", jitCompilation);
129
146
  const dropMessageCompiler = jitCompilation ? !!options.dropMessageCompiler : false;
130
147
  debug("dropMessageCompiler", dropMessageCompiler);
@@ -398,12 +415,6 @@ const unplugin = createUnplugin((options = {}, meta) => {
398
415
  },
399
416
  resolveId(id, importer) {
400
417
  debug("resolveId", id, importer);
401
- if (id === INTLIFY_BUNDLE_IMPORT_DEPRECTED_ID) {
402
- warn(
403
- `deprected '${INTLIFY_BUNDLE_IMPORT_DEPRECTED_ID}', you should switch to '${INTLIFY_BUNDLE_IMPORT_ID}'`
404
- );
405
- return asVirtualId(id, meta.framework);
406
- }
407
418
  if (id === INTLIFY_BUNDLE_IMPORT_ID) {
408
419
  return asVirtualId(id, meta.framework);
409
420
  }
@@ -412,9 +423,7 @@ const unplugin = createUnplugin((options = {}, meta) => {
412
423
  async load(id) {
413
424
  debug("load", id);
414
425
  const { query } = parseVueRequest(id);
415
- if ([INTLIFY_BUNDLE_IMPORT_DEPRECTED_ID, INTLIFY_BUNDLE_IMPORT_ID].includes(
416
- getVirtualId(id, meta.framework)
417
- ) && include) {
426
+ if (INTLIFY_BUNDLE_IMPORT_ID === getVirtualId(id, meta.framework) && include) {
418
427
  let resourcePaths = [];
419
428
  const includePaths = isArray(include) ? include : [include];
420
429
  for (const inc of includePaths) {
@@ -448,7 +457,7 @@ const unplugin = createUnplugin((options = {}, meta) => {
448
457
  return true;
449
458
  } else {
450
459
  const { filename } = parseVueRequest(id);
451
- return filename.endsWith("vue") || filename.endsWith(INTLIFY_BUNDLE_IMPORT_ID) || filename.endsWith(INTLIFY_BUNDLE_IMPORT_DEPRECTED_ID) || /\.(json5?|ya?ml)$/.test(filename) && filter(filename);
460
+ return filename.endsWith("vue") || filename.endsWith(INTLIFY_BUNDLE_IMPORT_ID) || /\.(json5?|ya?ml)$/.test(filename) && filter(filename);
452
461
  }
453
462
  },
454
463
  async transform(code, id) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlify/unplugin-vue-i18n",
3
- "version": "1.6.0",
3
+ "version": "3.0.0",
4
4
  "description": "unplugin for Vue I18n",
5
5
  "author": {
6
6
  "name": "kazuya kawaguchi",
@@ -28,7 +28,7 @@
28
28
  "dependencies": {
29
29
  "@intlify/bundle-utils": "^7.4.0",
30
30
  "@intlify/shared": "^9.4.0",
31
- "@rollup/pluginutils": "^5.0.2",
31
+ "@rollup/pluginutils": "^5.1.0",
32
32
  "@vue/compiler-sfc": "^3.2.47",
33
33
  "debug": "^4.3.3",
34
34
  "fast-glob": "^3.2.12",