@intlify/unplugin-vue-i18n 0.5.0 → 0.6.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/CHANGELOG.md +9 -0
- package/lib/index.cjs +106 -41
- package/lib/index.mjs +107 -42
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
|
|
2
|
+
## @intlify/unplugin-vue-i18n@0.6.0 (2022-09-19)
|
|
3
|
+
|
|
4
|
+
#### :bug: Bug Fixes
|
|
5
|
+
* [#180](https://github.com/intlify/bundle-tools/pull/180) fix(unplugin-vue-i18n): improve compilation error handling ([@kazupon](https://github.com/kazupon))
|
|
6
|
+
|
|
7
|
+
#### Committers: 1
|
|
8
|
+
- kazuya kawaguchi ([@kazupon](https://github.com/kazupon))
|
|
9
|
+
|
|
10
|
+
|
|
2
11
|
## @intlify/unplugin-vue-i18n@0.5.0 (2022-07-26)
|
|
3
12
|
|
|
4
13
|
#### :star: Features
|
package/lib/index.cjs
CHANGED
|
@@ -27,7 +27,9 @@ function parseVueRequest(id) {
|
|
|
27
27
|
const [filename, rawQuery] = id.split(`?`, 2);
|
|
28
28
|
const params = new URLSearchParams(rawQuery);
|
|
29
29
|
const ret = {};
|
|
30
|
-
const langPart = Object.keys(Object.fromEntries(params)).find(
|
|
30
|
+
const langPart = Object.keys(Object.fromEntries(params)).find(
|
|
31
|
+
(key) => /lang\./i.test(key)
|
|
32
|
+
);
|
|
31
33
|
ret.vue = params.has("vue");
|
|
32
34
|
ret.global = params.has("global");
|
|
33
35
|
ret.src = params.has("src");
|
|
@@ -152,7 +154,9 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
152
154
|
config.resolve.alias[getAliasName()] = `${installedPkg}/dist/${installedPkg}.runtime.esm-bundler.js`;
|
|
153
155
|
}
|
|
154
156
|
debug(`alias name: ${getAliasName()}`);
|
|
155
|
-
debug(
|
|
157
|
+
debug(
|
|
158
|
+
`set ${installedPkg} runtime only: ${installedPkg}/dist/${installedPkg}.runtime.esm-bundler.js`
|
|
159
|
+
);
|
|
156
160
|
} else if (command === "serve" && installedPkg === "petite-vue-i18n" && useVueI18nImportName) {
|
|
157
161
|
normalizeConfigResolveAlias(config.resolve, meta.framework);
|
|
158
162
|
if (shared.isArray(config.resolve.alias)) {
|
|
@@ -167,15 +171,21 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
167
171
|
}
|
|
168
172
|
config.define = config.define || {};
|
|
169
173
|
config.define["__VUE_I18N_LEGACY_API__"] = !compositionOnly;
|
|
170
|
-
debug(
|
|
174
|
+
debug(
|
|
175
|
+
`set __VUE_I18N_LEGACY_API__ is '${config.define["__VUE_I18N_LEGACY_API__"]}'`
|
|
176
|
+
);
|
|
171
177
|
config.define["__VUE_I18N_FULL_INSTALL__"] = fullInstall;
|
|
172
|
-
debug(
|
|
178
|
+
debug(
|
|
179
|
+
`set __VUE_I18N_FULL_INSTALL__ is '${config.define["__VUE_I18N_FULL_INSTALL__"]}'`
|
|
180
|
+
);
|
|
173
181
|
config.define["__VUE_I18N_PROD_DEVTOOLS__"] = false;
|
|
174
182
|
},
|
|
175
183
|
configResolved(config) {
|
|
176
184
|
isProduction = config.isProduction;
|
|
177
185
|
sourceMap = config.command === "build" ? !!config.build.sourcemap : false;
|
|
178
|
-
debug(
|
|
186
|
+
debug(
|
|
187
|
+
`configResolved: isProduction = ${isProduction}, sourceMap = ${sourceMap}`
|
|
188
|
+
);
|
|
179
189
|
const jsonPlugin = config.plugins.find((p) => p.name === "vite:json");
|
|
180
190
|
if (jsonPlugin) {
|
|
181
191
|
const orgTransform = jsonPlugin.transform;
|
|
@@ -203,11 +213,13 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
203
213
|
}
|
|
204
214
|
loadWebpack().then((webpack) => {
|
|
205
215
|
if (webpack) {
|
|
206
|
-
compiler.options.plugins.push(
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
216
|
+
compiler.options.plugins.push(
|
|
217
|
+
new webpack.DefinePlugin({
|
|
218
|
+
__VUE_I18N_LEGACY_API__: JSON.stringify(compositionOnly),
|
|
219
|
+
__VUE_I18N_FULL_INSTALL__: JSON.stringify(fullInstall),
|
|
220
|
+
__INTLIFY_PROD_DEVTOOLS__: "false"
|
|
221
|
+
})
|
|
222
|
+
);
|
|
211
223
|
debug(`set __VUE_I18N_LEGACY_API__ is '${compositionOnly}'`);
|
|
212
224
|
debug(`set __VUE_I18N_FULL_INSTALL__ is '${fullInstall}'`);
|
|
213
225
|
} else {
|
|
@@ -225,7 +237,9 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
225
237
|
resolveId(id, importer) {
|
|
226
238
|
debug("resolveId", id, importer);
|
|
227
239
|
if (id === INTLIFY_BUNDLE_IMPORT_DEPRECTED_ID) {
|
|
228
|
-
warn(
|
|
240
|
+
warn(
|
|
241
|
+
`deprected '${INTLIFY_BUNDLE_IMPORT_DEPRECTED_ID}', you should switch to '${INTLIFY_BUNDLE_IMPORT_ID}'`
|
|
242
|
+
);
|
|
229
243
|
return asVirtualId(id, meta.framework);
|
|
230
244
|
}
|
|
231
245
|
if (id === INTLIFY_BUNDLE_IMPORT_ID) {
|
|
@@ -235,19 +249,28 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
235
249
|
async load(id) {
|
|
236
250
|
debug("load", id);
|
|
237
251
|
const { query } = parseVueRequest(id);
|
|
238
|
-
if ([INTLIFY_BUNDLE_IMPORT_DEPRECTED_ID, INTLIFY_BUNDLE_IMPORT_ID].includes(
|
|
252
|
+
if ([INTLIFY_BUNDLE_IMPORT_DEPRECTED_ID, INTLIFY_BUNDLE_IMPORT_ID].includes(
|
|
253
|
+
getVirtualId(id, meta.framework)
|
|
254
|
+
) && include) {
|
|
239
255
|
let resourcePaths = [];
|
|
240
256
|
const includePaths = shared.isArray(include) ? include : [include];
|
|
241
257
|
for (const inc of includePaths) {
|
|
242
258
|
resourcePaths = [...resourcePaths, ...await fg__default(inc)];
|
|
243
259
|
}
|
|
244
|
-
resourcePaths = resourcePaths.filter(
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
260
|
+
resourcePaths = resourcePaths.filter(
|
|
261
|
+
(el, pos) => resourcePaths.indexOf(el) === pos
|
|
262
|
+
);
|
|
263
|
+
const code = await generateBundleResources(
|
|
264
|
+
resourcePaths,
|
|
265
|
+
query,
|
|
266
|
+
isProduction,
|
|
267
|
+
{
|
|
268
|
+
forceStringify,
|
|
269
|
+
bridge,
|
|
270
|
+
exportESM: esm,
|
|
271
|
+
useClassComponent
|
|
272
|
+
}
|
|
273
|
+
);
|
|
251
274
|
return {
|
|
252
275
|
code,
|
|
253
276
|
map: { mappings: "" }
|
|
@@ -272,16 +295,26 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
272
295
|
if (/\.(json5?|ya?ml)$/.test(id) && filter(id)) {
|
|
273
296
|
langInfo = pathe.parse(filename).ext;
|
|
274
297
|
const generate = /\.?json5?/.test(langInfo) ? bundleUtils.generateJSON : bundleUtils.generateYAML;
|
|
275
|
-
const parseOptions = getOptions(
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
298
|
+
const parseOptions = getOptions(
|
|
299
|
+
filename,
|
|
300
|
+
isProduction,
|
|
301
|
+
query,
|
|
302
|
+
sourceMap,
|
|
303
|
+
{
|
|
304
|
+
inSourceMap,
|
|
305
|
+
isGlobal: globalSFCScope,
|
|
306
|
+
useClassComponent,
|
|
307
|
+
bridge,
|
|
308
|
+
exportESM: esm,
|
|
309
|
+
forceStringify
|
|
310
|
+
}
|
|
311
|
+
);
|
|
283
312
|
debug("parseOptions", parseOptions);
|
|
284
|
-
const { code: generatedCode, map } = generate(
|
|
313
|
+
const { code: generatedCode, map } = generate(
|
|
314
|
+
code,
|
|
315
|
+
parseOptions,
|
|
316
|
+
bridge ? createBridgeCodeGenerator(code, query) : void 0
|
|
317
|
+
);
|
|
285
318
|
debug("generated code", generatedCode);
|
|
286
319
|
debug("sourcemap", map, sourceMap);
|
|
287
320
|
if (code === generatedCode)
|
|
@@ -305,17 +338,33 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
305
338
|
}
|
|
306
339
|
debug("langInfo", langInfo);
|
|
307
340
|
const generate = /\.?json5?/.test(langInfo) ? bundleUtils.generateJSON : bundleUtils.generateYAML;
|
|
308
|
-
const parseOptions = getOptions(
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
341
|
+
const parseOptions = getOptions(
|
|
342
|
+
filename,
|
|
343
|
+
isProduction,
|
|
344
|
+
query,
|
|
345
|
+
sourceMap,
|
|
346
|
+
{
|
|
347
|
+
inSourceMap,
|
|
348
|
+
isGlobal: globalSFCScope,
|
|
349
|
+
useClassComponent,
|
|
350
|
+
bridge,
|
|
351
|
+
exportESM: esm,
|
|
352
|
+
forceStringify
|
|
353
|
+
}
|
|
354
|
+
);
|
|
316
355
|
debug("parseOptions", parseOptions);
|
|
317
|
-
const source = await getCode(
|
|
318
|
-
|
|
356
|
+
const source = await getCode(
|
|
357
|
+
code,
|
|
358
|
+
filename,
|
|
359
|
+
sourceMap,
|
|
360
|
+
query,
|
|
361
|
+
meta.framework
|
|
362
|
+
);
|
|
363
|
+
const { code: generatedCode, map } = generate(
|
|
364
|
+
source,
|
|
365
|
+
parseOptions,
|
|
366
|
+
bridge ? createBridgeCodeGenerator(source, query) : void 0
|
|
367
|
+
);
|
|
319
368
|
debug("generated code", generatedCode);
|
|
320
369
|
debug("sourcemap", map, sourceMap);
|
|
321
370
|
if (code === generatedCode)
|
|
@@ -378,7 +427,11 @@ async function generateBundleResources(resources, query, isProduction, {
|
|
|
378
427
|
forceStringify
|
|
379
428
|
});
|
|
380
429
|
parseOptions.type = "bare";
|
|
381
|
-
const { code } = generate(
|
|
430
|
+
const { code } = generate(
|
|
431
|
+
source,
|
|
432
|
+
parseOptions,
|
|
433
|
+
bridge ? createBridgeCodeGenerator(source, query) : void 0
|
|
434
|
+
);
|
|
382
435
|
debug("generated code", code);
|
|
383
436
|
codes.push(`${JSON.stringify(name)}: ${code}`);
|
|
384
437
|
}
|
|
@@ -439,8 +492,20 @@ function getOptions(filename, isProduction, query, sourceMap, {
|
|
|
439
492
|
onWarn: (msg) => {
|
|
440
493
|
warn(`${filename} ${msg}`);
|
|
441
494
|
},
|
|
442
|
-
onError: (msg) => {
|
|
443
|
-
|
|
495
|
+
onError: (msg, extra) => {
|
|
496
|
+
const codeFrame = shared.generateCodeFrame(
|
|
497
|
+
extra?.source || extra?.location?.source || "",
|
|
498
|
+
extra?.location?.start.column,
|
|
499
|
+
extra?.location?.end.column
|
|
500
|
+
);
|
|
501
|
+
const errMssage = `${msg} (error code: ${extra?.code}) in ${filename}
|
|
502
|
+
target message: ${extra?.source}
|
|
503
|
+
target message path: ${extra?.path}
|
|
504
|
+
|
|
505
|
+
${codeFrame}
|
|
506
|
+
`;
|
|
507
|
+
error(errMssage);
|
|
508
|
+
throw new Error(errMssage);
|
|
444
509
|
}
|
|
445
510
|
};
|
|
446
511
|
if (isCustomBlock(query)) {
|
package/lib/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { createUnplugin } from 'unplugin';
|
|
|
2
2
|
import { normalize, parse } from 'pathe';
|
|
3
3
|
import createDebug from 'debug';
|
|
4
4
|
import fg from 'fast-glob';
|
|
5
|
-
import { isString, isArray, isBoolean, isObject,
|
|
5
|
+
import { isString, isArray, isBoolean, isObject, isNumber, isEmptyObject, assign, generateCodeFrame } from '@intlify/shared';
|
|
6
6
|
import { createFilter } from '@rollup/pluginutils';
|
|
7
7
|
import { checkInstallPackage, generateJSON, generateYAML } from '@intlify/bundle-utils';
|
|
8
8
|
import { parse as parse$1 } from '@vue/compiler-sfc';
|
|
@@ -15,7 +15,9 @@ function parseVueRequest(id) {
|
|
|
15
15
|
const [filename, rawQuery] = id.split(`?`, 2);
|
|
16
16
|
const params = new URLSearchParams(rawQuery);
|
|
17
17
|
const ret = {};
|
|
18
|
-
const langPart = Object.keys(Object.fromEntries(params)).find(
|
|
18
|
+
const langPart = Object.keys(Object.fromEntries(params)).find(
|
|
19
|
+
(key) => /lang\./i.test(key)
|
|
20
|
+
);
|
|
19
21
|
ret.vue = params.has("vue");
|
|
20
22
|
ret.global = params.has("global");
|
|
21
23
|
ret.src = params.has("src");
|
|
@@ -140,7 +142,9 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
140
142
|
config.resolve.alias[getAliasName()] = `${installedPkg}/dist/${installedPkg}.runtime.esm-bundler.js`;
|
|
141
143
|
}
|
|
142
144
|
debug(`alias name: ${getAliasName()}`);
|
|
143
|
-
debug(
|
|
145
|
+
debug(
|
|
146
|
+
`set ${installedPkg} runtime only: ${installedPkg}/dist/${installedPkg}.runtime.esm-bundler.js`
|
|
147
|
+
);
|
|
144
148
|
} else if (command === "serve" && installedPkg === "petite-vue-i18n" && useVueI18nImportName) {
|
|
145
149
|
normalizeConfigResolveAlias(config.resolve, meta.framework);
|
|
146
150
|
if (isArray(config.resolve.alias)) {
|
|
@@ -155,15 +159,21 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
155
159
|
}
|
|
156
160
|
config.define = config.define || {};
|
|
157
161
|
config.define["__VUE_I18N_LEGACY_API__"] = !compositionOnly;
|
|
158
|
-
debug(
|
|
162
|
+
debug(
|
|
163
|
+
`set __VUE_I18N_LEGACY_API__ is '${config.define["__VUE_I18N_LEGACY_API__"]}'`
|
|
164
|
+
);
|
|
159
165
|
config.define["__VUE_I18N_FULL_INSTALL__"] = fullInstall;
|
|
160
|
-
debug(
|
|
166
|
+
debug(
|
|
167
|
+
`set __VUE_I18N_FULL_INSTALL__ is '${config.define["__VUE_I18N_FULL_INSTALL__"]}'`
|
|
168
|
+
);
|
|
161
169
|
config.define["__VUE_I18N_PROD_DEVTOOLS__"] = false;
|
|
162
170
|
},
|
|
163
171
|
configResolved(config) {
|
|
164
172
|
isProduction = config.isProduction;
|
|
165
173
|
sourceMap = config.command === "build" ? !!config.build.sourcemap : false;
|
|
166
|
-
debug(
|
|
174
|
+
debug(
|
|
175
|
+
`configResolved: isProduction = ${isProduction}, sourceMap = ${sourceMap}`
|
|
176
|
+
);
|
|
167
177
|
const jsonPlugin = config.plugins.find((p) => p.name === "vite:json");
|
|
168
178
|
if (jsonPlugin) {
|
|
169
179
|
const orgTransform = jsonPlugin.transform;
|
|
@@ -191,11 +201,13 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
191
201
|
}
|
|
192
202
|
loadWebpack().then((webpack) => {
|
|
193
203
|
if (webpack) {
|
|
194
|
-
compiler.options.plugins.push(
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
204
|
+
compiler.options.plugins.push(
|
|
205
|
+
new webpack.DefinePlugin({
|
|
206
|
+
__VUE_I18N_LEGACY_API__: JSON.stringify(compositionOnly),
|
|
207
|
+
__VUE_I18N_FULL_INSTALL__: JSON.stringify(fullInstall),
|
|
208
|
+
__INTLIFY_PROD_DEVTOOLS__: "false"
|
|
209
|
+
})
|
|
210
|
+
);
|
|
199
211
|
debug(`set __VUE_I18N_LEGACY_API__ is '${compositionOnly}'`);
|
|
200
212
|
debug(`set __VUE_I18N_FULL_INSTALL__ is '${fullInstall}'`);
|
|
201
213
|
} else {
|
|
@@ -213,7 +225,9 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
213
225
|
resolveId(id, importer) {
|
|
214
226
|
debug("resolveId", id, importer);
|
|
215
227
|
if (id === INTLIFY_BUNDLE_IMPORT_DEPRECTED_ID) {
|
|
216
|
-
warn(
|
|
228
|
+
warn(
|
|
229
|
+
`deprected '${INTLIFY_BUNDLE_IMPORT_DEPRECTED_ID}', you should switch to '${INTLIFY_BUNDLE_IMPORT_ID}'`
|
|
230
|
+
);
|
|
217
231
|
return asVirtualId(id, meta.framework);
|
|
218
232
|
}
|
|
219
233
|
if (id === INTLIFY_BUNDLE_IMPORT_ID) {
|
|
@@ -223,19 +237,28 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
223
237
|
async load(id) {
|
|
224
238
|
debug("load", id);
|
|
225
239
|
const { query } = parseVueRequest(id);
|
|
226
|
-
if ([INTLIFY_BUNDLE_IMPORT_DEPRECTED_ID, INTLIFY_BUNDLE_IMPORT_ID].includes(
|
|
240
|
+
if ([INTLIFY_BUNDLE_IMPORT_DEPRECTED_ID, INTLIFY_BUNDLE_IMPORT_ID].includes(
|
|
241
|
+
getVirtualId(id, meta.framework)
|
|
242
|
+
) && include) {
|
|
227
243
|
let resourcePaths = [];
|
|
228
244
|
const includePaths = isArray(include) ? include : [include];
|
|
229
245
|
for (const inc of includePaths) {
|
|
230
246
|
resourcePaths = [...resourcePaths, ...await fg(inc)];
|
|
231
247
|
}
|
|
232
|
-
resourcePaths = resourcePaths.filter(
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
248
|
+
resourcePaths = resourcePaths.filter(
|
|
249
|
+
(el, pos) => resourcePaths.indexOf(el) === pos
|
|
250
|
+
);
|
|
251
|
+
const code = await generateBundleResources(
|
|
252
|
+
resourcePaths,
|
|
253
|
+
query,
|
|
254
|
+
isProduction,
|
|
255
|
+
{
|
|
256
|
+
forceStringify,
|
|
257
|
+
bridge,
|
|
258
|
+
exportESM: esm,
|
|
259
|
+
useClassComponent
|
|
260
|
+
}
|
|
261
|
+
);
|
|
239
262
|
return {
|
|
240
263
|
code,
|
|
241
264
|
map: { mappings: "" }
|
|
@@ -260,16 +283,26 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
260
283
|
if (/\.(json5?|ya?ml)$/.test(id) && filter(id)) {
|
|
261
284
|
langInfo = parse(filename).ext;
|
|
262
285
|
const generate = /\.?json5?/.test(langInfo) ? generateJSON : generateYAML;
|
|
263
|
-
const parseOptions = getOptions(
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
286
|
+
const parseOptions = getOptions(
|
|
287
|
+
filename,
|
|
288
|
+
isProduction,
|
|
289
|
+
query,
|
|
290
|
+
sourceMap,
|
|
291
|
+
{
|
|
292
|
+
inSourceMap,
|
|
293
|
+
isGlobal: globalSFCScope,
|
|
294
|
+
useClassComponent,
|
|
295
|
+
bridge,
|
|
296
|
+
exportESM: esm,
|
|
297
|
+
forceStringify
|
|
298
|
+
}
|
|
299
|
+
);
|
|
271
300
|
debug("parseOptions", parseOptions);
|
|
272
|
-
const { code: generatedCode, map } = generate(
|
|
301
|
+
const { code: generatedCode, map } = generate(
|
|
302
|
+
code,
|
|
303
|
+
parseOptions,
|
|
304
|
+
bridge ? createBridgeCodeGenerator(code, query) : void 0
|
|
305
|
+
);
|
|
273
306
|
debug("generated code", generatedCode);
|
|
274
307
|
debug("sourcemap", map, sourceMap);
|
|
275
308
|
if (code === generatedCode)
|
|
@@ -293,17 +326,33 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
293
326
|
}
|
|
294
327
|
debug("langInfo", langInfo);
|
|
295
328
|
const generate = /\.?json5?/.test(langInfo) ? generateJSON : generateYAML;
|
|
296
|
-
const parseOptions = getOptions(
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
329
|
+
const parseOptions = getOptions(
|
|
330
|
+
filename,
|
|
331
|
+
isProduction,
|
|
332
|
+
query,
|
|
333
|
+
sourceMap,
|
|
334
|
+
{
|
|
335
|
+
inSourceMap,
|
|
336
|
+
isGlobal: globalSFCScope,
|
|
337
|
+
useClassComponent,
|
|
338
|
+
bridge,
|
|
339
|
+
exportESM: esm,
|
|
340
|
+
forceStringify
|
|
341
|
+
}
|
|
342
|
+
);
|
|
304
343
|
debug("parseOptions", parseOptions);
|
|
305
|
-
const source = await getCode(
|
|
306
|
-
|
|
344
|
+
const source = await getCode(
|
|
345
|
+
code,
|
|
346
|
+
filename,
|
|
347
|
+
sourceMap,
|
|
348
|
+
query,
|
|
349
|
+
meta.framework
|
|
350
|
+
);
|
|
351
|
+
const { code: generatedCode, map } = generate(
|
|
352
|
+
source,
|
|
353
|
+
parseOptions,
|
|
354
|
+
bridge ? createBridgeCodeGenerator(source, query) : void 0
|
|
355
|
+
);
|
|
307
356
|
debug("generated code", generatedCode);
|
|
308
357
|
debug("sourcemap", map, sourceMap);
|
|
309
358
|
if (code === generatedCode)
|
|
@@ -366,7 +415,11 @@ async function generateBundleResources(resources, query, isProduction, {
|
|
|
366
415
|
forceStringify
|
|
367
416
|
});
|
|
368
417
|
parseOptions.type = "bare";
|
|
369
|
-
const { code } = generate(
|
|
418
|
+
const { code } = generate(
|
|
419
|
+
source,
|
|
420
|
+
parseOptions,
|
|
421
|
+
bridge ? createBridgeCodeGenerator(source, query) : void 0
|
|
422
|
+
);
|
|
370
423
|
debug("generated code", code);
|
|
371
424
|
codes.push(`${JSON.stringify(name)}: ${code}`);
|
|
372
425
|
}
|
|
@@ -427,8 +480,20 @@ function getOptions(filename, isProduction, query, sourceMap, {
|
|
|
427
480
|
onWarn: (msg) => {
|
|
428
481
|
warn(`${filename} ${msg}`);
|
|
429
482
|
},
|
|
430
|
-
onError: (msg) => {
|
|
431
|
-
|
|
483
|
+
onError: (msg, extra) => {
|
|
484
|
+
const codeFrame = generateCodeFrame(
|
|
485
|
+
extra?.source || extra?.location?.source || "",
|
|
486
|
+
extra?.location?.start.column,
|
|
487
|
+
extra?.location?.end.column
|
|
488
|
+
);
|
|
489
|
+
const errMssage = `${msg} (error code: ${extra?.code}) in ${filename}
|
|
490
|
+
target message: ${extra?.source}
|
|
491
|
+
target message path: ${extra?.path}
|
|
492
|
+
|
|
493
|
+
${codeFrame}
|
|
494
|
+
`;
|
|
495
|
+
error(errMssage);
|
|
496
|
+
throw new Error(errMssage);
|
|
432
497
|
}
|
|
433
498
|
};
|
|
434
499
|
if (isCustomBlock(query)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlify/unplugin-vue-i18n",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "unplugin for Vue I18n",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "kazuya kawaguchi",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@intlify/bundle-utils": "
|
|
25
|
+
"@intlify/bundle-utils": "^3.1.2",
|
|
26
26
|
"@intlify/shared": "next",
|
|
27
27
|
"@rollup/pluginutils": "^4.2.0",
|
|
28
28
|
"@vue/compiler-sfc": "^3.2.23",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"mlly": "^0.5.2",
|
|
40
|
-
"unbuild": "^0.
|
|
40
|
+
"unbuild": "^0.8.11"
|
|
41
41
|
},
|
|
42
42
|
"engines": {
|
|
43
43
|
"node": ">= 14.16"
|