Skip to content

Commit 7114e8e

Browse files
authored
breaking(unplugin-vue-i18n): drop jitCompilation option (#362)
* breaking(unplugin-vue-i18n): drop `jitCompilation` option * chore: update test * fix: bump
1 parent 06e76ba commit 7114e8e

18 files changed

+2532
-326
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
strategy:
2323
matrix:
2424
os: [ubuntu-latest]
25-
node: [18.x]
25+
node: [18, 20, 22]
2626
steps:
2727
- name: Checkout
2828
uses: actions/checkout@v4

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
}
2424
},
2525
"devDependencies": {
26-
"@intlify/core-base": "^9.13.1",
26+
"@intlify/core-base": "10.0.0-alpha.5",
2727
"@kazupon/lerna-changelog": "^4.3.0",
2828
"@octokit/rest": "^18.6.0",
2929
"@rollup/plugin-alias": "^3.1.5",
@@ -83,7 +83,7 @@
8383
"vite": "^4.4.9",
8484
"vitest": "^0.29.8",
8585
"vue": "^2.6.14",
86-
"vue-i18n": "9.13.1",
86+
"vue-i18n": "10.0.0-alpha.5",
8787
"vue-loader": "^16.3.0",
8888
"vue-loader15": "npm:[email protected]",
8989
"vue-loader17": "npm:[email protected]",

packages/unplugin-vue-i18n/README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -353,13 +353,11 @@ This plugin will automatically select and bundle `petite-vue-i18n` build accordi
353353
- **Default:** `true`
354354

355355
> [!IMPORTANT]
356-
'jitCompilation' option now defaults to `true` from 3.0.
356+
'jitCompilation' option is deprected in v5.
357+
This option will be supported with vue-i18n until v9 latest version.
357358

358359
Whether locale mesages should be compiled by JIT (Just in Time) compilation with vue-i18n's message compiler.
359360

360-
> [!NOTE]
361-
This option works with vue-i18n v9.3 and later.
362-
363361
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.
364362

365363
> [!WARNING]
@@ -374,7 +372,10 @@ This plugin will automatically select and bundle `petite-vue-i18n` build accordi
374372

375373
Whether to tree-shake message compiler when we will be bundling.
376374

377-
If you chose to use this option, you will need to enable `jitCompilation` option.
375+
If do you will use this option, you need to enable `jitCompilation` option.
376+
377+
> [NOTE]
378+
> After v5 or later, this option can be set with or without `jitCompilation`.
378379
379380
> [!NOTE]
380381
This option works with vue-i18n v9.3 and later.

packages/unplugin-vue-i18n/examples/vite/vite.config.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ export default defineConfig({
2020
plugins: [
2121
vue(),
2222
vueI18n({
23-
include: path.resolve(__dirname, './src/locales/**'),
24-
jitCompilation: true
23+
include: path.resolve(__dirname, './src/locales/**')
2524
})
2625
]
2726
})

packages/unplugin-vue-i18n/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
},
2828
"dependencies": {
2929
"@intlify/bundle-utils": "^8.0.0",
30-
"@intlify/shared": "^9.4.0",
30+
"@intlify/shared": "^10.0.0-alpha.5",
3131
"@rollup/pluginutils": "^5.1.0",
3232
"@vue/compiler-sfc": "^3.2.47",
3333
"debug": "^4.3.3",

packages/unplugin-vue-i18n/src/index.ts

Lines changed: 9 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,7 @@ export const unplugin = createUnplugin<PluginOptions>((options = {}, meta) => {
8787
: true
8888
debug('runtimeOnly', runtimeOnly)
8989

90-
const jitCompilation = isBoolean(options.jitCompilation)
91-
? options.jitCompilation
92-
: true
93-
debug('jitCompilation', jitCompilation)
94-
95-
const dropMessageCompiler = jitCompilation
96-
? !!options.dropMessageCompiler
97-
: false
90+
const dropMessageCompiler = !!options.dropMessageCompiler
9891
debug('dropMessageCompiler', dropMessageCompiler)
9992

10093
// prettier-ignore
@@ -233,10 +226,6 @@ export const unplugin = createUnplugin<PluginOptions>((options = {}, meta) => {
233226
debug(
234227
`set __VUE_I18N_FULL_INSTALL__ is '${config.define['__VUE_I18N_FULL_INSTALL__']}'`
235228
)
236-
config.define['__INTLIFY_JIT_COMPILATION__'] = jitCompilation
237-
debug(
238-
`set __INTLIFY_JIT_COMPILATION__ is '${config.define['__INTLIFY_JIT_COMPILATION__']}'`
239-
)
240229
config.define['__INTLIFY_DROP_MESSAGE_COMPILER__'] = dropMessageCompiler
241230
debug(
242231
`set __INTLIFY_DROP_MESSAGE_COMPILER__ is '${config.define['__INTLIFY_DROP_MESSAGE_COMPILER__']}'`
@@ -327,7 +316,7 @@ export const unplugin = createUnplugin<PluginOptions>((options = {}, meta) => {
327316
allowDynamic,
328317
strictMessage,
329318
escapeHtml,
330-
jit: jitCompilation,
319+
jit: true,
331320
onlyLocales,
332321
forceStringify
333322
}
@@ -342,12 +331,7 @@ export const unplugin = createUnplugin<PluginOptions>((options = {}, meta) => {
342331

343332
return {
344333
code: generatedCode,
345-
// prettier-ignore
346-
map: (jitCompilation
347-
? { mappings: '' }
348-
: sourceMap
349-
? map
350-
: { mappings: '' }) as any // eslint-disable-line @typescript-eslint/no-explicit-any
334+
map: { mappings: '' }
351335
}
352336
} else {
353337
return result
@@ -519,7 +503,7 @@ export const unplugin = createUnplugin<PluginOptions>((options = {}, meta) => {
519503
allowDynamic,
520504
strictMessage,
521505
escapeHtml,
522-
jit: jitCompilation,
506+
jit: true,
523507
onlyLocales,
524508
forceStringify
525509
}
@@ -535,11 +519,7 @@ export const unplugin = createUnplugin<PluginOptions>((options = {}, meta) => {
535519
return {
536520
code: generatedCode,
537521
// prettier-ignore
538-
map: (jitCompilation
539-
? { mappings: '' }
540-
: sourceMap
541-
? map
542-
: { mappings: '' }) as any // eslint-disable-line @typescript-eslint/no-explicit-any
522+
map: { mappings: '' }
543523
}
544524
} else {
545525
// TODO: support virtual import identifier
@@ -574,7 +554,7 @@ export const unplugin = createUnplugin<PluginOptions>((options = {}, meta) => {
574554
inSourceMap,
575555
isGlobal: globalSFCScope,
576556
useClassComponent,
577-
jit: jitCompilation,
557+
jit: true,
578558
strictMessage,
579559
escapeHtml,
580560
onlyLocales,
@@ -599,11 +579,7 @@ export const unplugin = createUnplugin<PluginOptions>((options = {}, meta) => {
599579
return {
600580
code: generatedCode,
601581
// prettier-ignore
602-
map: (jitCompilation
603-
? { mappings: '' }
604-
: sourceMap
605-
? map
606-
: { mappings: '' }) as any // eslint-disable-line @typescript-eslint/no-explicit-any
582+
map: { mappings: '' }
607583
}
608584
}
609585
}
@@ -669,7 +645,7 @@ async function generateBundleResources(
669645
strictMessage = true,
670646
escapeHtml = false,
671647
useClassComponent = false,
672-
jit = false
648+
jit = true
673649
}: {
674650
forceStringify?: boolean
675651
isGlobal?: boolean
@@ -790,7 +766,7 @@ function getOptions(
790766
allowDynamic = false,
791767
strictMessage = true,
792768
escapeHtml = false,
793-
jit = false
769+
jit = true
794770
}: {
795771
inSourceMap?: RawSourceMap
796772
forceStringify?: boolean

packages/unplugin-vue-i18n/src/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ export interface PluginOptions {
33
include?: string | string[]
44
onlyLocales?: string | string[]
55
allowDynamic?: boolean
6-
jitCompilation?: boolean
76
dropMessageCompiler?: boolean
87
runtimeOnly?: boolean
98
compositionOnly?: boolean

packages/unplugin-vue-i18n/test/utils.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ export async function bundleVite(
4242
? options.strictMessage
4343
: true
4444
options.escapeHtml = !!options.escapeHtml
45-
options.jitCompilation = !!options.jitCompilation
4645

4746
const alias: Record<string, string> = {
4847
vue: 'vue/dist/vue.runtime.esm-browser.js'
@@ -167,7 +166,6 @@ export async function bundleAndRun(
167166
? options.strictMessage
168167
: true
169168
options.escapeHtml = !!options.escapeHtml
170-
options.jitCompilation = !!options.jitCompilation
171169

172170
const { code, map } = await bundler(fixture, options)
173171

0 commit comments

Comments
 (0)