@intlify/unplugin-vue-i18n 11.1.1 → 11.1.2
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 +26 -41
- package/lib/index.mjs +26 -41
- package/package.json +6 -2
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
|
-
|
|
238
|
-
|
|
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
|
|
303
|
-
|
|
304
|
-
if (
|
|
305
|
-
const
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
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
|
-
|
|
321
|
-
if (
|
|
322
|
-
|
|
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
|
-
|
|
226
|
-
|
|
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
|
|
291
|
-
|
|
292
|
-
if (
|
|
293
|
-
const
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
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
|
-
|
|
309
|
-
if (
|
|
310
|
-
|
|
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.
|
|
3
|
+
"version": "11.1.2",
|
|
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,6 +19,9 @@
|
|
|
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
|
}
|
|
@@ -35,7 +39,7 @@
|
|
|
35
39
|
"picocolors": "^1.0.0",
|
|
36
40
|
"unplugin": "^2.3.4",
|
|
37
41
|
"vue": "^3.5.21",
|
|
38
|
-
"@intlify/bundle-utils": "11.1.
|
|
42
|
+
"@intlify/bundle-utils": "11.1.2"
|
|
39
43
|
},
|
|
40
44
|
"devDependencies": {
|
|
41
45
|
"@intlify/core-base": "next",
|