Skip to content

Commit

Permalink
breaking(unplugin-vue-i18n): deperecate around some options for Vue 2 (
Browse files Browse the repository at this point in the history
  • Loading branch information
kazupon committed Mar 7, 2024
1 parent 082b0ab commit b24b995
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
18 changes: 15 additions & 3 deletions packages/unplugin-vue-i18n/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,10 @@ This plugin will automatically select and bundle `petite-vue-i18n` build accordi
### `jitCompilation`

- **Type:** `boolean`
- **Default:** `false`
- **Default:** `true`

> [!IMPORTANT]
'jitCompilation' option now defaults to `true` from 3.0.

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

Expand All @@ -374,10 +377,10 @@ Whether to tree-shake message compiler when we will be bundling.
If do you will use this option, you need to enable `jitCompilation` option.

> [!NOTE]
> This option works with vue-i18n v9.3 and later.
This option works with vue-i18n v9.3 and later.

> [!WARNING]
> If you enable this option, **you should check resources in your application are pre-compiled with this plugin.** If you will be loading resources dynamically from the back-end via the API, enabling this option do not work because there is not message compiler.
If you enable this option, **you should check resources in your application are pre-compiled with this plugin.** If you will be loading resources dynamically from the back-end via the API, enabling this option do not work because there is not message compiler.

### `ssr`

Expand Down Expand Up @@ -541,6 +544,9 @@ If do you will use this option, you need to enable `jitCompilation` option.
- **Type:** `boolean`
- **Default:** `false`

> [!WARNING]
'bridge' option is deprecated, sinece Vue 2 was EOL on 2023. that option will be removed in 4.0.`

The mode to birdge the i18n custom block to work in both vue-i18n@v8.x and vue-i18n@v9.x environments.

To support in a smooth transition from vue-i18n@v8.x to vue-i18n@v9.x, we provide a mode that bundles the i18n custom block to be available in either version.
Expand All @@ -553,6 +559,9 @@ If do you will use this option, you need to enable `jitCompilation` option.
- **Type:** `boolean`
- **Default:** `false`

> [!WARNING]
'legacy' option is deprecated, sinece Vue 2 was EOL on 2023. that option will be removed in 4.0.`

This option supports Vue I18n v8.x compatibility for resources in i18n custom blocks.

> [!NOTE]
Expand All @@ -563,6 +572,9 @@ If do you will use this option, you need to enable `jitCompilation` option.
- **Type:** `string`
- **Default:** `undefined`

> [!WARNING]
'vueVersion' option is deprecated, sinece Vue 2 was EOL on 2023. that option will be removed in 4.0.`

The version of Vue that will be used by Vue I18n. This option is enabled when the `legacy` option is `true`.

Available values are `'v2.6'` and `'v2.7'`.
Expand Down
24 changes: 23 additions & 1 deletion packages/unplugin-vue-i18n/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ const installedPkg = checkInstallPackage('@intlify/unplugin-vue-i18n', debug)
const installedVueI18nBridge = checkVueI18nBridgeInstallPackage(debug)
const vueI18nVersion = getVueI18nVersion(debug)

if (vueI18nVersion === '8') {
warn(`vue-i18n@8 is not supported, since sinece Vue 2 was EOL on 2023.`)
}

export const unplugin = createUnplugin<PluginOptions>((options = {}, meta) => {
debug('plugin options:', options, meta.framework)

Expand Down Expand Up @@ -83,21 +87,39 @@ export const unplugin = createUnplugin<PluginOptions>((options = {}, meta) => {

const bridge = !!options.bridge
debug('bridge', bridge)
if (bridge) {
warn(
`'bridge' option is deprecated, sinece Vue 2 was EOL on 2023. that option will be removed in 4.0.`
)
}

const legacy = !!options.legacy
debug('legacy', legacy)
if (legacy) {
warn(
`'legacy' option is deprecated, sinece Vue 2 was EOL on 2023. that option will be removed in 4.0.`
)
}

const vueVersion = isString(options.vueVersion)
? options.vueVersion
: undefined
if (!vueVersion) {
warn(
`'vueVersion' option is deprecated, sinece Vue 2 was EOL on 2023. that option will be removed in 4.0.`
)
}

const runtimeOnly = isBoolean(options.runtimeOnly)
? options.runtimeOnly
: true
debug('runtimeOnly', runtimeOnly)

const jitCompilation = !!options.jitCompilation
const jitCompilation = isBoolean(options.jitCompilation)
? options.jitCompilation
: true
debug('jitCompilation', jitCompilation)

const dropMessageCompiler = jitCompilation
? !!options.dropMessageCompiler
: false
Expand Down

0 comments on commit b24b995

Please sign in to comment.