@intlify/unplugin-vue-i18n 11.1.1 → 11.2.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.
Files changed (3) hide show
  1. package/lib/index.cjs +26 -41
  2. package/lib/index.mjs +26 -41
  3. package/package.json +16 -12
package/lib/index.cjs CHANGED
@@ -204,19 +204,6 @@ function resourcePlugin({
204
204
  escapeHtml,
205
205
  transformI18nBlock
206
206
  }, meta, collector) {
207
- let viteModule = null;
208
- async function getViteModule() {
209
- if (viteModule != null) {
210
- return viteModule;
211
- }
212
- try {
213
- viteModule = await import('vite');
214
- } catch (e) {
215
- error(`vite not found, please install vite.`, e.message);
216
- throw e;
217
- }
218
- return viteModule;
219
- }
220
207
  function resolveIncludeExclude() {
221
208
  const customBlockInclude = meta.framework === "vite" ? RE_SFC_I18N_CUSTOM_BLOCK : RE_SFC_I18N_WEBPACK_CUSTOM_BLOCK;
222
209
  return include ? [[...include, customBlockInclude], exclude] : [[RE_RESOURCE_FORMAT, customBlockInclude], exclude];
@@ -233,15 +220,12 @@ function resourcePlugin({
233
220
  if (meta.framework == "webpack") {
234
221
  debug$3("Using filter for webpack");
235
222
  _filter = pluginutils.createFilter(...resolveIncludeExclude());
223
+ } else if (hasViteJsonPlugin) {
224
+ debug$3("Using filter for rollup-vite");
225
+ _filter = pluginutils.createFilter(...resolveIncludeExcludeForLegacy());
236
226
  } else {
237
- const viteModule2 = await getViteModule();
238
- if (viteModule2.rolldownVersion) {
239
- debug$3("Using filter for rolldown-vite");
240
- _filter = pluginutils.createFilter(...resolveIncludeExclude());
241
- } else {
242
- debug$3("Using filter for rollup-vite");
243
- _filter = pluginutils.createFilter(...resolveIncludeExcludeForLegacy());
244
- }
227
+ debug$3("Using filter for rolldown-vite");
228
+ _filter = pluginutils.createFilter(...resolveIncludeExclude());
245
229
  }
246
230
  return _filter;
247
231
  }
@@ -250,6 +234,7 @@ function resourcePlugin({
250
234
  };
251
235
  let isProduction = false;
252
236
  let sourceMap = false;
237
+ let hasViteJsonPlugin = false;
253
238
  const vueI18nAliasName = module;
254
239
  debug$3(`vue-i18n alias name: ${vueI18nAliasName}`);
255
240
  let vuePlugin = null;
@@ -299,28 +284,28 @@ function resourcePlugin({
299
284
  isProduction = config.isProduction;
300
285
  sourceMap = config.command === "build" ? !!config.build.sourcemap : false;
301
286
  debug$3(`configResolved: isProduction = ${isProduction}, sourceMap = ${sourceMap}`);
302
- const isRolldownVite = !!(await getViteModule()).rolldownVersion;
303
- debug$3(`Using ${isRolldownVite ? "rolldown-vite" : "vite"} for the build`);
304
- if (!isRolldownVite) {
305
- const jsonPlugin = getVitePlugin(config, "vite:json");
306
- if (jsonPlugin) {
307
- const orgTransform = "handler" in jsonPlugin.transform ? jsonPlugin.transform.handler : jsonPlugin.transform;
308
- async function overrideJson(code, id) {
309
- const filter = await getFilter();
310
- if (!/\.json$/.test(id) || filter(id)) {
311
- return;
312
- }
313
- const { query } = parseVueRequest(id);
314
- if (query.vue) {
315
- return;
316
- }
317
- debug$3("org json plugin");
318
- return orgTransform.apply(this, [code, id]);
287
+ const jsonPlugin = getVitePlugin(config, "vite:json");
288
+ hasViteJsonPlugin = !!jsonPlugin;
289
+ if (jsonPlugin && jsonPlugin.transform) {
290
+ const transform = jsonPlugin.transform;
291
+ const isObjectHook = typeof transform !== "function" && "handler" in transform;
292
+ const orgTransform = isObjectHook ? transform.handler : transform;
293
+ async function overrideJson(code, id) {
294
+ const filter = await getFilter();
295
+ if (!/\.json$/.test(id) || filter(id)) {
296
+ return;
319
297
  }
320
- jsonPlugin.transform = overrideJson;
321
- if ("handler" in jsonPlugin.transform) {
322
- jsonPlugin.transform.handler = overrideJson;
298
+ const { query } = parseVueRequest(id);
299
+ if (query.vue) {
300
+ return;
323
301
  }
302
+ debug$3("org json plugin");
303
+ return orgTransform.apply(this, [code, id]);
304
+ }
305
+ if (isObjectHook) {
306
+ transform.handler = overrideJson;
307
+ } else {
308
+ jsonPlugin.transform = overrideJson;
324
309
  }
325
310
  }
326
311
  },
package/lib/index.mjs CHANGED
@@ -192,19 +192,6 @@ function resourcePlugin({
192
192
  escapeHtml,
193
193
  transformI18nBlock
194
194
  }, meta, collector) {
195
- let viteModule = null;
196
- async function getViteModule() {
197
- if (viteModule != null) {
198
- return viteModule;
199
- }
200
- try {
201
- viteModule = await import('vite');
202
- } catch (e) {
203
- error(`vite not found, please install vite.`, e.message);
204
- throw e;
205
- }
206
- return viteModule;
207
- }
208
195
  function resolveIncludeExclude() {
209
196
  const customBlockInclude = meta.framework === "vite" ? RE_SFC_I18N_CUSTOM_BLOCK : RE_SFC_I18N_WEBPACK_CUSTOM_BLOCK;
210
197
  return include ? [[...include, customBlockInclude], exclude] : [[RE_RESOURCE_FORMAT, customBlockInclude], exclude];
@@ -221,15 +208,12 @@ function resourcePlugin({
221
208
  if (meta.framework == "webpack") {
222
209
  debug$3("Using filter for webpack");
223
210
  _filter = createFilter(...resolveIncludeExclude());
211
+ } else if (hasViteJsonPlugin) {
212
+ debug$3("Using filter for rollup-vite");
213
+ _filter = createFilter(...resolveIncludeExcludeForLegacy());
224
214
  } else {
225
- const viteModule2 = await getViteModule();
226
- if (viteModule2.rolldownVersion) {
227
- debug$3("Using filter for rolldown-vite");
228
- _filter = createFilter(...resolveIncludeExclude());
229
- } else {
230
- debug$3("Using filter for rollup-vite");
231
- _filter = createFilter(...resolveIncludeExcludeForLegacy());
232
- }
215
+ debug$3("Using filter for rolldown-vite");
216
+ _filter = createFilter(...resolveIncludeExclude());
233
217
  }
234
218
  return _filter;
235
219
  }
@@ -238,6 +222,7 @@ function resourcePlugin({
238
222
  };
239
223
  let isProduction = false;
240
224
  let sourceMap = false;
225
+ let hasViteJsonPlugin = false;
241
226
  const vueI18nAliasName = module;
242
227
  debug$3(`vue-i18n alias name: ${vueI18nAliasName}`);
243
228
  let vuePlugin = null;
@@ -287,28 +272,28 @@ function resourcePlugin({
287
272
  isProduction = config.isProduction;
288
273
  sourceMap = config.command === "build" ? !!config.build.sourcemap : false;
289
274
  debug$3(`configResolved: isProduction = ${isProduction}, sourceMap = ${sourceMap}`);
290
- const isRolldownVite = !!(await getViteModule()).rolldownVersion;
291
- debug$3(`Using ${isRolldownVite ? "rolldown-vite" : "vite"} for the build`);
292
- if (!isRolldownVite) {
293
- const jsonPlugin = getVitePlugin(config, "vite:json");
294
- if (jsonPlugin) {
295
- const orgTransform = "handler" in jsonPlugin.transform ? jsonPlugin.transform.handler : jsonPlugin.transform;
296
- async function overrideJson(code, id) {
297
- const filter = await getFilter();
298
- if (!/\.json$/.test(id) || filter(id)) {
299
- return;
300
- }
301
- const { query } = parseVueRequest(id);
302
- if (query.vue) {
303
- return;
304
- }
305
- debug$3("org json plugin");
306
- return orgTransform.apply(this, [code, id]);
275
+ const jsonPlugin = getVitePlugin(config, "vite:json");
276
+ hasViteJsonPlugin = !!jsonPlugin;
277
+ if (jsonPlugin && jsonPlugin.transform) {
278
+ const transform = jsonPlugin.transform;
279
+ const isObjectHook = typeof transform !== "function" && "handler" in transform;
280
+ const orgTransform = isObjectHook ? transform.handler : transform;
281
+ async function overrideJson(code, id) {
282
+ const filter = await getFilter();
283
+ if (!/\.json$/.test(id) || filter(id)) {
284
+ return;
307
285
  }
308
- jsonPlugin.transform = overrideJson;
309
- if ("handler" in jsonPlugin.transform) {
310
- jsonPlugin.transform.handler = overrideJson;
286
+ const { query } = parseVueRequest(id);
287
+ if (query.vue) {
288
+ return;
311
289
  }
290
+ debug$3("org json plugin");
291
+ return orgTransform.apply(this, [code, id]);
292
+ }
293
+ if (isObjectHook) {
294
+ transform.handler = overrideJson;
295
+ } else {
296
+ jsonPlugin.transform = overrideJson;
312
297
  }
313
298
  }
314
299
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlify/unplugin-vue-i18n",
3
- "version": "11.1.1",
3
+ "version": "11.2.0",
4
4
  "description": "unplugin for Vue I18n",
5
5
  "author": {
6
6
  "name": "kazuya kawaguchi",
@@ -11,6 +11,7 @@
11
11
  },
12
12
  "peerDependencies": {
13
13
  "petite-vue-i18n": "*",
14
+ "vite": "^6.0.0 || ^7.0.0 || ^8.0.0",
14
15
  "vue": "^3.2.25",
15
16
  "vue-i18n": "*"
16
17
  },
@@ -18,13 +19,16 @@
18
19
  "petite-vue-i18n": {
19
20
  "optional": true
20
21
  },
22
+ "vite": {
23
+ "optional": true
24
+ },
21
25
  "vue-i18n": {
22
26
  "optional": true
23
27
  }
24
28
  },
25
29
  "dependencies": {
26
30
  "@eslint-community/eslint-utils": "^4.4.0",
27
- "@intlify/shared": "^11.1.12",
31
+ "@intlify/shared": "~11.4.2",
28
32
  "@intlify/vue-i18n-extensions": "^8.0.0",
29
33
  "@rollup/pluginutils": "^5.1.0",
30
34
  "@typescript-eslint/scope-manager": "^8.13.0",
@@ -34,29 +38,29 @@
34
38
  "fast-glob": "^3.2.12",
35
39
  "picocolors": "^1.0.0",
36
40
  "unplugin": "^2.3.4",
37
- "vue": "^3.5.21",
38
- "@intlify/bundle-utils": "11.1.1"
41
+ "vue": "~3.5.34",
42
+ "@intlify/bundle-utils": "11.2.0"
39
43
  },
40
44
  "devDependencies": {
41
45
  "@intlify/core-base": "next",
42
46
  "@types/debug": "^4.1.5",
43
47
  "@types/jsdom": "^16.2.5",
44
48
  "@types/memory-fs": "^0.3.2",
45
- "@types/node": "^22.18.4",
46
- "@vitejs/plugin-vue": "^5.2.4",
49
+ "@types/node": "^25.7.0",
50
+ "@vitejs/plugin-vue": "5.2.4",
47
51
  "jsdom": "^25.0.1",
48
52
  "memory-fs": "^0.5.0",
49
53
  "source-map-js": "^1.2.1",
50
- "ts-loader": "^9.5.4",
54
+ "ts-loader": "~9.5.7",
51
55
  "unbuild": "^3.6.1",
52
- "vite": "^6.3.6",
53
- "rollup-vite": "npm:vite@^6.3.5",
54
- "vue-loader": "^17.4.2",
55
- "webpack": "^5.101.3",
56
+ "vite": "6.3.5",
57
+ "rollup-vite": "npm:vite@6.3.5",
58
+ "vue-loader": "~17.4.2",
59
+ "webpack": "~5.106.2",
56
60
  "webpack-merge": "^5.9.0"
57
61
  },
58
62
  "engines": {
59
- "node": ">= 20"
63
+ "node": ">= 22.13"
60
64
  },
61
65
  "files": [
62
66
  "lib",