@intlify/unplugin-vue-i18n 7.0.0-beta.0 → 7.0.0-beta.1
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 +21 -1
- package/lib/index.cjs +102 -49
- package/lib/index.mjs +102 -49
- package/lib/rspack.cjs +22 -0
- package/lib/rspack.d.cts +6 -0
- package/lib/rspack.d.mts +6 -0
- package/lib/rspack.d.ts +6 -0
- package/lib/rspack.mjs +20 -0
- package/package.json +9 -4
- package/rspack.d.ts +1 -0
package/README.md
CHANGED
|
@@ -59,6 +59,25 @@ module.exports = {
|
|
|
59
59
|
|
|
60
60
|
<br></details>
|
|
61
61
|
|
|
62
|
+
<details>
|
|
63
|
+
<summary>Rspack</summary><br>
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
const VueI18nPlugin = require('@intlify/unplugin-vue-i18n/rspack')
|
|
67
|
+
|
|
68
|
+
// rspack.config.js
|
|
69
|
+
module.exports = {
|
|
70
|
+
/* ... */
|
|
71
|
+
plugins: [
|
|
72
|
+
VueI18nPlugin({
|
|
73
|
+
/* options */
|
|
74
|
+
})
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
<br></details>
|
|
80
|
+
|
|
62
81
|
<details>
|
|
63
82
|
<summary>Nuxt</summary><br>
|
|
64
83
|
|
|
@@ -379,7 +398,7 @@ If you are using petite-vue-i18n, you will need to set this value.
|
|
|
379
398
|
|
|
380
399
|
Whether locale messages should be compiled by JIT (Just in Time) compilation with vue-i18n's message compiler.
|
|
381
400
|
|
|
382
|
-
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 messages with
|
|
401
|
+
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 messages with programmatic.
|
|
383
402
|
|
|
384
403
|
> [!WARNING]
|
|
385
404
|
> Enabling JIT compilation causes the message compiler to generate AST objects for locale messages 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.
|
|
@@ -424,6 +443,7 @@ If do you will use this option, you need to enable `jitCompilation` option.
|
|
|
424
443
|
```
|
|
425
444
|
- vite config: `resolve.alias`
|
|
426
445
|
- webpack config: `resolve.alias`
|
|
446
|
+
- rspack config: `resolve.alias`
|
|
427
447
|
```
|
|
428
448
|
|
|
429
449
|
If `false` is specified, Vue I18n (vue-i18n) package.json `module` field will be used.
|
package/lib/index.cjs
CHANGED
|
@@ -331,45 +331,30 @@ function resourcePlugin({
|
|
|
331
331
|
}
|
|
332
332
|
},
|
|
333
333
|
webpack(compiler) {
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
334
|
+
webpackLike(compiler, "webpack", {
|
|
335
|
+
isProduction,
|
|
336
|
+
meta,
|
|
337
|
+
sourceMap,
|
|
338
|
+
getVueI18nAliasPath,
|
|
339
|
+
vueI18nAliasName,
|
|
340
|
+
ssrBuild,
|
|
341
|
+
runtimeOnly,
|
|
342
|
+
fullInstall,
|
|
343
|
+
filter
|
|
344
344
|
});
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
})
|
|
358
|
-
);
|
|
359
|
-
debug$2(`set __VUE_I18N_FULL_INSTALL__ is '${fullInstall}'`);
|
|
360
|
-
} else {
|
|
361
|
-
debug$2("ignore vue-i18n feature flags with webpack.DefinePlugin");
|
|
362
|
-
}
|
|
345
|
+
},
|
|
346
|
+
rspack(compiler) {
|
|
347
|
+
webpackLike(compiler, "rspack", {
|
|
348
|
+
isProduction,
|
|
349
|
+
meta,
|
|
350
|
+
sourceMap,
|
|
351
|
+
getVueI18nAliasPath,
|
|
352
|
+
vueI18nAliasName,
|
|
353
|
+
ssrBuild,
|
|
354
|
+
runtimeOnly,
|
|
355
|
+
fullInstall,
|
|
356
|
+
filter
|
|
363
357
|
});
|
|
364
|
-
if (compiler.options.module) {
|
|
365
|
-
compiler.options.module.rules.push({
|
|
366
|
-
test: /\.(json5?|ya?ml)$/,
|
|
367
|
-
type: "javascript/auto",
|
|
368
|
-
include(resource) {
|
|
369
|
-
return filter(resource);
|
|
370
|
-
}
|
|
371
|
-
});
|
|
372
|
-
}
|
|
373
358
|
},
|
|
374
359
|
resolveId(id, importer) {
|
|
375
360
|
debug$2("resolveId", id, importer);
|
|
@@ -377,6 +362,9 @@ function resourcePlugin({
|
|
|
377
362
|
return asVirtualId(id, meta.framework);
|
|
378
363
|
}
|
|
379
364
|
},
|
|
365
|
+
loadInclude(id) {
|
|
366
|
+
return INTLIFY_BUNDLE_IMPORT_ID === getVirtualId(id, meta.framework);
|
|
367
|
+
},
|
|
380
368
|
async load(id) {
|
|
381
369
|
debug$2("load", id);
|
|
382
370
|
if (INTLIFY_BUNDLE_IMPORT_ID === getVirtualId(id, meta.framework) && include) {
|
|
@@ -508,34 +496,99 @@ function resourcePlugin({
|
|
|
508
496
|
function getGenerator(ext, defaultGen = bundleUtils.generateJSON) {
|
|
509
497
|
return /\.?json5?$/.test(ext) ? bundleUtils.generateJSON : /\.ya?ml$/.test(ext) ? bundleUtils.generateYAML : /\.([c|m]?js|[c|m]?ts)$/.test(ext) ? bundleUtils.generateJavaScript : defaultGen;
|
|
510
498
|
}
|
|
499
|
+
function webpackLike(compiler, framework, {
|
|
500
|
+
isProduction,
|
|
501
|
+
sourceMap,
|
|
502
|
+
meta,
|
|
503
|
+
getVueI18nAliasPath,
|
|
504
|
+
vueI18nAliasName,
|
|
505
|
+
ssrBuild,
|
|
506
|
+
runtimeOnly,
|
|
507
|
+
fullInstall,
|
|
508
|
+
filter
|
|
509
|
+
}) {
|
|
510
|
+
isProduction = compiler.options.mode !== "development";
|
|
511
|
+
sourceMap = !!compiler.options.devtool;
|
|
512
|
+
debug$2(
|
|
513
|
+
`${framework}: isProduction = ${isProduction}, sourceMap = ${sourceMap}`
|
|
514
|
+
);
|
|
515
|
+
compiler.options.resolve = normalizeConfigResolveAlias(
|
|
516
|
+
compiler.options.resolve,
|
|
517
|
+
meta.framework
|
|
518
|
+
);
|
|
519
|
+
compiler.options.resolve.alias[vueI18nAliasName] = getVueI18nAliasPath({
|
|
520
|
+
ssr: ssrBuild,
|
|
521
|
+
runtimeOnly
|
|
522
|
+
});
|
|
523
|
+
debug$2(
|
|
524
|
+
`set ${vueI18nAliasName}: ${getVueI18nAliasPath({
|
|
525
|
+
ssr: ssrBuild,
|
|
526
|
+
runtimeOnly
|
|
527
|
+
})}`
|
|
528
|
+
);
|
|
529
|
+
const loader = framework === "webpack" ? loadWebpack : loadRspack;
|
|
530
|
+
loader().then((mod) => {
|
|
531
|
+
if (mod) {
|
|
532
|
+
compiler.options.plugins.push(
|
|
533
|
+
// @ts-expect-error type issue
|
|
534
|
+
new mod.DefinePlugin({
|
|
535
|
+
__VUE_I18N_FULL_INSTALL__: JSON.stringify(fullInstall),
|
|
536
|
+
__INTLIFY_PROD_DEVTOOLS__: "false"
|
|
537
|
+
})
|
|
538
|
+
);
|
|
539
|
+
debug$2(`set __VUE_I18N_FULL_INSTALL__ is '${fullInstall}'`);
|
|
540
|
+
} else {
|
|
541
|
+
debug$2(`ignore vue-i18n feature flags with ${framework}.DefinePlugin`);
|
|
542
|
+
}
|
|
543
|
+
});
|
|
544
|
+
if (compiler.options.module) {
|
|
545
|
+
compiler.options.module.rules.push({
|
|
546
|
+
test: /\.(json5?|ya?ml)$/,
|
|
547
|
+
type: "javascript/auto",
|
|
548
|
+
include(resource) {
|
|
549
|
+
return filter(resource);
|
|
550
|
+
}
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
}
|
|
511
554
|
function normalizeConfigResolveAlias(resolve, framework) {
|
|
512
555
|
if (resolve && resolve.alias) {
|
|
513
556
|
return resolve;
|
|
514
557
|
}
|
|
558
|
+
const webpackLike2 = framework === "webpack" || framework === "rspack";
|
|
515
559
|
if (!resolve) {
|
|
516
560
|
if (framework === "vite") {
|
|
517
561
|
return { alias: [] };
|
|
518
|
-
} else if (
|
|
562
|
+
} else if (webpackLike2) {
|
|
519
563
|
return { alias: {} };
|
|
520
564
|
}
|
|
521
565
|
} else if (!resolve.alias) {
|
|
522
566
|
if (framework === "vite") {
|
|
523
567
|
resolve.alias = [];
|
|
524
568
|
return resolve;
|
|
525
|
-
} else if (
|
|
569
|
+
} else if (webpackLike2) {
|
|
526
570
|
resolve.alias = {};
|
|
527
571
|
return resolve;
|
|
528
572
|
}
|
|
529
573
|
}
|
|
530
574
|
}
|
|
531
575
|
async function loadWebpack() {
|
|
532
|
-
let webpack = null;
|
|
533
576
|
try {
|
|
534
|
-
|
|
577
|
+
const mod = await import('webpack');
|
|
578
|
+
return mod.default || mod;
|
|
535
579
|
} catch (_e) {
|
|
536
580
|
warn(`webpack not found, please install webpack.`);
|
|
537
581
|
}
|
|
538
|
-
return
|
|
582
|
+
return null;
|
|
583
|
+
}
|
|
584
|
+
async function loadRspack() {
|
|
585
|
+
try {
|
|
586
|
+
const { rspack } = await import('@rspack/core');
|
|
587
|
+
return rspack;
|
|
588
|
+
} catch (_e) {
|
|
589
|
+
warn(`rspack not found, please install rspack.`);
|
|
590
|
+
}
|
|
591
|
+
return null;
|
|
539
592
|
}
|
|
540
593
|
async function generateBundleResources(resources, isProduction, {
|
|
541
594
|
forceStringify = false,
|
|
@@ -597,9 +650,9 @@ async function getCode(source, filename, sourceMap, query, parser, framework = "
|
|
|
597
650
|
if (!shared.isNumber(index)) {
|
|
598
651
|
raiseError(`unexpected index: ${index}`);
|
|
599
652
|
}
|
|
600
|
-
if (framework === "webpack") {
|
|
653
|
+
if (framework === "webpack" || framework === "rspack") {
|
|
601
654
|
if (issuerPath) {
|
|
602
|
-
debug$2(`getCode (
|
|
655
|
+
debug$2(`getCode (${framework}) ${index} via issuerPath`, issuerPath);
|
|
603
656
|
return await getRaw(filename);
|
|
604
657
|
} else {
|
|
605
658
|
const result = parser(await getRaw(filename), {
|
|
@@ -609,7 +662,7 @@ async function getCode(source, filename, sourceMap, query, parser, framework = "
|
|
|
609
662
|
const block = result.descriptor.customBlocks[index];
|
|
610
663
|
if (block) {
|
|
611
664
|
const code = block.src ? await getRaw(block.src) : block.content;
|
|
612
|
-
debug$2(`getCode (
|
|
665
|
+
debug$2(`getCode (${framework}) ${index} from SFC`, code);
|
|
613
666
|
return code;
|
|
614
667
|
} else {
|
|
615
668
|
return source;
|
|
@@ -968,17 +1021,17 @@ function resolveIdentifier(localVariables, returnVariable) {
|
|
|
968
1021
|
const debug = createDebug__default(resolveNamespace("root"));
|
|
969
1022
|
const unpluginFactory = (options = {}, meta) => {
|
|
970
1023
|
debug("meta framework", meta.framework);
|
|
971
|
-
if (!["vite", "webpack"].includes(meta.framework)) {
|
|
972
|
-
raiseError(`This plugin is supported 'vite' and '
|
|
1024
|
+
if (!["vite", "webpack", "rspack"].includes(meta.framework)) {
|
|
1025
|
+
raiseError(`This plugin is supported 'vite', 'webpack' and 'rspack' only`);
|
|
973
1026
|
}
|
|
974
1027
|
debug("plugin options (resolving):", options);
|
|
975
1028
|
const resolvedOptions = resolveOptions(options);
|
|
976
1029
|
debug("plugin options (resolved):", resolvedOptions);
|
|
977
1030
|
const plugins = [resourcePlugin(resolvedOptions, meta)];
|
|
978
1031
|
if (resolvedOptions.optimizeTranslationDirective) {
|
|
979
|
-
if (meta.framework === "webpack") {
|
|
1032
|
+
if (meta.framework === "webpack" || meta.framework === "rspack") {
|
|
980
1033
|
raiseError(
|
|
981
|
-
`The 'optimizeTranslationDirective' option still is not supported for
|
|
1034
|
+
`The 'optimizeTranslationDirective' option still is not supported for ${meta.framework}.
|
|
982
1035
|
We are waiting for your Pull Request \u{1F642}.`
|
|
983
1036
|
);
|
|
984
1037
|
}
|
package/lib/index.mjs
CHANGED
|
@@ -319,45 +319,30 @@ function resourcePlugin({
|
|
|
319
319
|
}
|
|
320
320
|
},
|
|
321
321
|
webpack(compiler) {
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
322
|
+
webpackLike(compiler, "webpack", {
|
|
323
|
+
isProduction,
|
|
324
|
+
meta,
|
|
325
|
+
sourceMap,
|
|
326
|
+
getVueI18nAliasPath,
|
|
327
|
+
vueI18nAliasName,
|
|
328
|
+
ssrBuild,
|
|
329
|
+
runtimeOnly,
|
|
330
|
+
fullInstall,
|
|
331
|
+
filter
|
|
332
332
|
});
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
})
|
|
346
|
-
);
|
|
347
|
-
debug$2(`set __VUE_I18N_FULL_INSTALL__ is '${fullInstall}'`);
|
|
348
|
-
} else {
|
|
349
|
-
debug$2("ignore vue-i18n feature flags with webpack.DefinePlugin");
|
|
350
|
-
}
|
|
333
|
+
},
|
|
334
|
+
rspack(compiler) {
|
|
335
|
+
webpackLike(compiler, "rspack", {
|
|
336
|
+
isProduction,
|
|
337
|
+
meta,
|
|
338
|
+
sourceMap,
|
|
339
|
+
getVueI18nAliasPath,
|
|
340
|
+
vueI18nAliasName,
|
|
341
|
+
ssrBuild,
|
|
342
|
+
runtimeOnly,
|
|
343
|
+
fullInstall,
|
|
344
|
+
filter
|
|
351
345
|
});
|
|
352
|
-
if (compiler.options.module) {
|
|
353
|
-
compiler.options.module.rules.push({
|
|
354
|
-
test: /\.(json5?|ya?ml)$/,
|
|
355
|
-
type: "javascript/auto",
|
|
356
|
-
include(resource) {
|
|
357
|
-
return filter(resource);
|
|
358
|
-
}
|
|
359
|
-
});
|
|
360
|
-
}
|
|
361
346
|
},
|
|
362
347
|
resolveId(id, importer) {
|
|
363
348
|
debug$2("resolveId", id, importer);
|
|
@@ -365,6 +350,9 @@ function resourcePlugin({
|
|
|
365
350
|
return asVirtualId(id, meta.framework);
|
|
366
351
|
}
|
|
367
352
|
},
|
|
353
|
+
loadInclude(id) {
|
|
354
|
+
return INTLIFY_BUNDLE_IMPORT_ID === getVirtualId(id, meta.framework);
|
|
355
|
+
},
|
|
368
356
|
async load(id) {
|
|
369
357
|
debug$2("load", id);
|
|
370
358
|
if (INTLIFY_BUNDLE_IMPORT_ID === getVirtualId(id, meta.framework) && include) {
|
|
@@ -496,34 +484,99 @@ function resourcePlugin({
|
|
|
496
484
|
function getGenerator(ext, defaultGen = generateJSON) {
|
|
497
485
|
return /\.?json5?$/.test(ext) ? generateJSON : /\.ya?ml$/.test(ext) ? generateYAML : /\.([c|m]?js|[c|m]?ts)$/.test(ext) ? generateJavaScript : defaultGen;
|
|
498
486
|
}
|
|
487
|
+
function webpackLike(compiler, framework, {
|
|
488
|
+
isProduction,
|
|
489
|
+
sourceMap,
|
|
490
|
+
meta,
|
|
491
|
+
getVueI18nAliasPath,
|
|
492
|
+
vueI18nAliasName,
|
|
493
|
+
ssrBuild,
|
|
494
|
+
runtimeOnly,
|
|
495
|
+
fullInstall,
|
|
496
|
+
filter
|
|
497
|
+
}) {
|
|
498
|
+
isProduction = compiler.options.mode !== "development";
|
|
499
|
+
sourceMap = !!compiler.options.devtool;
|
|
500
|
+
debug$2(
|
|
501
|
+
`${framework}: isProduction = ${isProduction}, sourceMap = ${sourceMap}`
|
|
502
|
+
);
|
|
503
|
+
compiler.options.resolve = normalizeConfigResolveAlias(
|
|
504
|
+
compiler.options.resolve,
|
|
505
|
+
meta.framework
|
|
506
|
+
);
|
|
507
|
+
compiler.options.resolve.alias[vueI18nAliasName] = getVueI18nAliasPath({
|
|
508
|
+
ssr: ssrBuild,
|
|
509
|
+
runtimeOnly
|
|
510
|
+
});
|
|
511
|
+
debug$2(
|
|
512
|
+
`set ${vueI18nAliasName}: ${getVueI18nAliasPath({
|
|
513
|
+
ssr: ssrBuild,
|
|
514
|
+
runtimeOnly
|
|
515
|
+
})}`
|
|
516
|
+
);
|
|
517
|
+
const loader = framework === "webpack" ? loadWebpack : loadRspack;
|
|
518
|
+
loader().then((mod) => {
|
|
519
|
+
if (mod) {
|
|
520
|
+
compiler.options.plugins.push(
|
|
521
|
+
// @ts-expect-error type issue
|
|
522
|
+
new mod.DefinePlugin({
|
|
523
|
+
__VUE_I18N_FULL_INSTALL__: JSON.stringify(fullInstall),
|
|
524
|
+
__INTLIFY_PROD_DEVTOOLS__: "false"
|
|
525
|
+
})
|
|
526
|
+
);
|
|
527
|
+
debug$2(`set __VUE_I18N_FULL_INSTALL__ is '${fullInstall}'`);
|
|
528
|
+
} else {
|
|
529
|
+
debug$2(`ignore vue-i18n feature flags with ${framework}.DefinePlugin`);
|
|
530
|
+
}
|
|
531
|
+
});
|
|
532
|
+
if (compiler.options.module) {
|
|
533
|
+
compiler.options.module.rules.push({
|
|
534
|
+
test: /\.(json5?|ya?ml)$/,
|
|
535
|
+
type: "javascript/auto",
|
|
536
|
+
include(resource) {
|
|
537
|
+
return filter(resource);
|
|
538
|
+
}
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
}
|
|
499
542
|
function normalizeConfigResolveAlias(resolve, framework) {
|
|
500
543
|
if (resolve && resolve.alias) {
|
|
501
544
|
return resolve;
|
|
502
545
|
}
|
|
546
|
+
const webpackLike2 = framework === "webpack" || framework === "rspack";
|
|
503
547
|
if (!resolve) {
|
|
504
548
|
if (framework === "vite") {
|
|
505
549
|
return { alias: [] };
|
|
506
|
-
} else if (
|
|
550
|
+
} else if (webpackLike2) {
|
|
507
551
|
return { alias: {} };
|
|
508
552
|
}
|
|
509
553
|
} else if (!resolve.alias) {
|
|
510
554
|
if (framework === "vite") {
|
|
511
555
|
resolve.alias = [];
|
|
512
556
|
return resolve;
|
|
513
|
-
} else if (
|
|
557
|
+
} else if (webpackLike2) {
|
|
514
558
|
resolve.alias = {};
|
|
515
559
|
return resolve;
|
|
516
560
|
}
|
|
517
561
|
}
|
|
518
562
|
}
|
|
519
563
|
async function loadWebpack() {
|
|
520
|
-
let webpack = null;
|
|
521
564
|
try {
|
|
522
|
-
|
|
565
|
+
const mod = await import('webpack');
|
|
566
|
+
return mod.default || mod;
|
|
523
567
|
} catch (_e) {
|
|
524
568
|
warn(`webpack not found, please install webpack.`);
|
|
525
569
|
}
|
|
526
|
-
return
|
|
570
|
+
return null;
|
|
571
|
+
}
|
|
572
|
+
async function loadRspack() {
|
|
573
|
+
try {
|
|
574
|
+
const { rspack } = await import('@rspack/core');
|
|
575
|
+
return rspack;
|
|
576
|
+
} catch (_e) {
|
|
577
|
+
warn(`rspack not found, please install rspack.`);
|
|
578
|
+
}
|
|
579
|
+
return null;
|
|
527
580
|
}
|
|
528
581
|
async function generateBundleResources(resources, isProduction, {
|
|
529
582
|
forceStringify = false,
|
|
@@ -585,9 +638,9 @@ async function getCode(source, filename, sourceMap, query, parser, framework = "
|
|
|
585
638
|
if (!isNumber(index)) {
|
|
586
639
|
raiseError(`unexpected index: ${index}`);
|
|
587
640
|
}
|
|
588
|
-
if (framework === "webpack") {
|
|
641
|
+
if (framework === "webpack" || framework === "rspack") {
|
|
589
642
|
if (issuerPath) {
|
|
590
|
-
debug$2(`getCode (
|
|
643
|
+
debug$2(`getCode (${framework}) ${index} via issuerPath`, issuerPath);
|
|
591
644
|
return await getRaw(filename);
|
|
592
645
|
} else {
|
|
593
646
|
const result = parser(await getRaw(filename), {
|
|
@@ -597,7 +650,7 @@ async function getCode(source, filename, sourceMap, query, parser, framework = "
|
|
|
597
650
|
const block = result.descriptor.customBlocks[index];
|
|
598
651
|
if (block) {
|
|
599
652
|
const code = block.src ? await getRaw(block.src) : block.content;
|
|
600
|
-
debug$2(`getCode (
|
|
653
|
+
debug$2(`getCode (${framework}) ${index} from SFC`, code);
|
|
601
654
|
return code;
|
|
602
655
|
} else {
|
|
603
656
|
return source;
|
|
@@ -956,17 +1009,17 @@ function resolveIdentifier(localVariables, returnVariable) {
|
|
|
956
1009
|
const debug = createDebug(resolveNamespace("root"));
|
|
957
1010
|
const unpluginFactory = (options = {}, meta) => {
|
|
958
1011
|
debug("meta framework", meta.framework);
|
|
959
|
-
if (!["vite", "webpack"].includes(meta.framework)) {
|
|
960
|
-
raiseError(`This plugin is supported 'vite' and '
|
|
1012
|
+
if (!["vite", "webpack", "rspack"].includes(meta.framework)) {
|
|
1013
|
+
raiseError(`This plugin is supported 'vite', 'webpack' and 'rspack' only`);
|
|
961
1014
|
}
|
|
962
1015
|
debug("plugin options (resolving):", options);
|
|
963
1016
|
const resolvedOptions = resolveOptions(options);
|
|
964
1017
|
debug("plugin options (resolved):", resolvedOptions);
|
|
965
1018
|
const plugins = [resourcePlugin(resolvedOptions, meta)];
|
|
966
1019
|
if (resolvedOptions.optimizeTranslationDirective) {
|
|
967
|
-
if (meta.framework === "webpack") {
|
|
1020
|
+
if (meta.framework === "webpack" || meta.framework === "rspack") {
|
|
968
1021
|
raiseError(
|
|
969
|
-
`The 'optimizeTranslationDirective' option still is not supported for
|
|
1022
|
+
`The 'optimizeTranslationDirective' option still is not supported for ${meta.framework}.
|
|
970
1023
|
We are waiting for your Pull Request \u{1F642}.`
|
|
971
1024
|
);
|
|
972
1025
|
}
|
package/lib/rspack.cjs
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const unplugin = require('unplugin');
|
|
4
|
+
const index = require('./index.cjs');
|
|
5
|
+
require('debug');
|
|
6
|
+
require('picocolors');
|
|
7
|
+
require('node:path');
|
|
8
|
+
require('pathe');
|
|
9
|
+
require('@intlify/shared');
|
|
10
|
+
require('@intlify/bundle-utils');
|
|
11
|
+
require('@rollup/pluginutils');
|
|
12
|
+
require('fast-glob');
|
|
13
|
+
require('node:fs');
|
|
14
|
+
require('vue/compiler-sfc');
|
|
15
|
+
require('@intlify/vue-i18n-extensions');
|
|
16
|
+
require('@typescript-eslint/scope-manager');
|
|
17
|
+
require('@typescript-eslint/typescript-estree');
|
|
18
|
+
require('@eslint-community/eslint-utils');
|
|
19
|
+
|
|
20
|
+
const rspack = unplugin.createRspackPlugin(index.unpluginFactory);
|
|
21
|
+
|
|
22
|
+
module.exports = rspack;
|
package/lib/rspack.d.cts
ADDED
package/lib/rspack.d.mts
ADDED
package/lib/rspack.d.ts
ADDED
package/lib/rspack.mjs
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createRspackPlugin } from 'unplugin';
|
|
2
|
+
import { unpluginFactory } from './index.mjs';
|
|
3
|
+
import 'debug';
|
|
4
|
+
import 'picocolors';
|
|
5
|
+
import 'node:path';
|
|
6
|
+
import 'pathe';
|
|
7
|
+
import '@intlify/shared';
|
|
8
|
+
import '@intlify/bundle-utils';
|
|
9
|
+
import '@rollup/pluginutils';
|
|
10
|
+
import 'fast-glob';
|
|
11
|
+
import 'node:fs';
|
|
12
|
+
import 'vue/compiler-sfc';
|
|
13
|
+
import '@intlify/vue-i18n-extensions';
|
|
14
|
+
import '@typescript-eslint/scope-manager';
|
|
15
|
+
import '@typescript-eslint/typescript-estree';
|
|
16
|
+
import '@eslint-community/eslint-utils';
|
|
17
|
+
|
|
18
|
+
const rspack = createRspackPlugin(unpluginFactory);
|
|
19
|
+
|
|
20
|
+
export { rspack as default };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlify/unplugin-vue-i18n",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "7.0.0-beta.
|
|
4
|
+
"version": "7.0.0-beta.1",
|
|
5
5
|
"description": "unplugin for Vue I18n",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "kazuya kawaguchi",
|
|
@@ -38,12 +38,12 @@
|
|
|
38
38
|
"pathe": "^1.0.0",
|
|
39
39
|
"picocolors": "^1.0.0",
|
|
40
40
|
"source-map-js": "^1.0.2",
|
|
41
|
-
"unplugin": "^
|
|
41
|
+
"unplugin": "^2.2.0",
|
|
42
42
|
"vue": "^3.4"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"
|
|
46
|
-
"
|
|
45
|
+
"@types/node": "^20.14.8",
|
|
46
|
+
"unbuild": "^2.0.0"
|
|
47
47
|
},
|
|
48
48
|
"engines": {
|
|
49
49
|
"node": ">= 18"
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
"unplugin",
|
|
60
60
|
"transform",
|
|
61
61
|
"webpack",
|
|
62
|
+
"rspack",
|
|
62
63
|
"vite",
|
|
63
64
|
"vue",
|
|
64
65
|
"vue-i18n"
|
|
@@ -80,6 +81,10 @@
|
|
|
80
81
|
"import": "./lib/webpack.mjs",
|
|
81
82
|
"require": "./lib/webpack.cjs"
|
|
82
83
|
},
|
|
84
|
+
"./rspack": {
|
|
85
|
+
"import": "./lib/rspack.mjs",
|
|
86
|
+
"require": "./lib/rspack.cjs"
|
|
87
|
+
},
|
|
83
88
|
"./types": {
|
|
84
89
|
"import": {
|
|
85
90
|
"types": "./lib/types.d.mts"
|
package/rspack.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './lib/rspack'
|