Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!(unplugin-vue-i18n):support vue-i18n v12 #436

Merged
merged 9 commits into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
coverage
node_modules
packages/rollup-plugin-vue-i18n/examples/legacy/index.js
packages/rollup-plugin-vue-i18n/examples/global/index.js
packages/rollup-plugin-vue-i18n/examples/composition/index.js
packages/vite-plugin-vue-i18n/examples/dist
Expand Down
1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ packages/**/examples/dist
packages/**/CHANGELOG.md
packages/rollup-plugin-vue-i18n/examples/composition/index.js
packages/rollup-plugin-vue-i18n/examples/global/index.js
packages/rollup-plugin-vue-i18n/examples/legacy/index.js
1 change: 0 additions & 1 deletion examples/vite/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import App from './App.vue'
import messages from '@intlify/unplugin-vue-i18n/messages'

const i18n = createI18n({
legacy: false,
locale: 'ja',
messages
})
Expand Down
1 change: 0 additions & 1 deletion examples/webpack/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import ja from './locales/ja.json'
import en from './locales/en.yaml'

const i18n = createI18n({
legacy: false,
locale: 'ja',
messages: {
en,
Expand Down
2 changes: 0 additions & 2 deletions packages/bundle-utils/src/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ export interface SourceLocationable {
*/
export interface CodeGenOptions {
type?: 'plain' | 'sfc' | 'bare'
legacy?: boolean
bridge?: boolean
exportESM?: boolean
onlyLocales?: string[]
source?: string
Expand Down
7 changes: 5 additions & 2 deletions packages/unplugin-vue-i18n/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -433,14 +433,17 @@ If do you will use this option, you need to enable `jitCompilation` option.

For more details, See [here](https://vue-i18n.intlify.dev/guide/advanced/optimization.html#reduce-bundle-size-with-feature-build-flags)

> [!CAUTION]
> This option will be removed in v7

### `fullInstall`

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

Whether to install the full set of APIs, components, etc. provided by Vue I18n. By default, all of them will be installed.

If `false` is specified, **buld-in components and directive will not be installed in vue and will be tree-shaken.**
If `false` is specified, **build-in components and directive will not be installed in vue and will be tree-shaken.**

For more details, See [here](https://vue-i18n.intlify.dev/guide/advanced/optimization.html#reduce-bundle-size-with-feature-build-flags)

Expand Down Expand Up @@ -614,7 +617,7 @@ If do you will use this option, you need to enable `jitCompilation` option.

Whether to use the import name of `petite-vue-i18n` with the same import name as vue-i18n (`import { xxx } from 'vue-i18n'`).

This option allows a smooth migration from `petite-vue-i18n` to `vue-i18n` and allows progressive enhacement.
This option allows a smooth migration from `petite-vue-i18n` to `vue-i18n` and allows progressive enhancement.

> [!IMPORTANT] > `useVueI18nImportName` option is deprecated in v5.
> This option will be supported with vue-i18n until v9 latest version.
Expand Down
8 changes: 0 additions & 8 deletions packages/unplugin-vue-i18n/src/core/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,6 @@ export function resolveOptions(options: PluginOptions) {

const dropMessageCompiler = !!options.dropMessageCompiler

// prettier-ignore
const compositionOnly = moduleType === 'vue-i18n'
? isBoolean(options.compositionOnly)
? options.compositionOnly
: true
: true

// prettier-ignore
const fullInstall = moduleType === 'vue-i18n'
? isBoolean(options.fullInstall)
Expand Down Expand Up @@ -90,7 +83,6 @@ export function resolveOptions(options: PluginOptions) {
globalSFCScope,
runtimeOnly,
dropMessageCompiler,
compositionOnly,
fullInstall,
ssrBuild,
allowDynamic,
Expand Down
6 changes: 1 addition & 5 deletions packages/unplugin-vue-i18n/src/core/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ export function resourcePlugin(
globalSFCScope,
runtimeOnly,
dropMessageCompiler,
compositionOnly,
fullInstall,
ssrBuild,
strictMessage,
Expand All @@ -68,7 +67,7 @@ export function resourcePlugin(
const filter = createFilter(include, exclude)
const getVueI18nAliasPath = ({ ssr = false, runtimeOnly = false }) => {
return `${module}/dist/${module}${runtimeOnly ? '.runtime' : ''}.${
!ssr ? 'esm-bundler.js' /* '.mjs' */ : 'node.mjs'
!ssr ? 'esm-bundler.js' : 'node.js'
}`
}
let isProduction = false
Expand Down Expand Up @@ -100,7 +99,6 @@ export function resourcePlugin(
config() {
const defineConfig = {
define: {
__VUE_I18N_LEGACY_API__: !compositionOnly,
__VUE_I18N_FULL_INSTALL__: fullInstall,
__INTLIFY_DROP_MESSAGE_COMPILER__: dropMessageCompiler,
__VUE_I18N_PROD_DEVTOOLS__: false
Expand Down Expand Up @@ -269,12 +267,10 @@ export function resourcePlugin(
if (webpack) {
compiler.options.plugins!.push(
new webpack.DefinePlugin({
__VUE_I18N_LEGACY_API__: JSON.stringify(compositionOnly),
__VUE_I18N_FULL_INSTALL__: JSON.stringify(fullInstall),
__INTLIFY_PROD_DEVTOOLS__: 'false'
})
)
debug(`set __VUE_I18N_LEGACY_API__ is '${compositionOnly}'`)
debug(`set __VUE_I18N_FULL_INSTALL__ is '${fullInstall}'`)
} else {
debug('ignore vue-i18n feature flags with webpack.DefinePlugin')
Expand Down
1 change: 0 additions & 1 deletion packages/unplugin-vue-i18n/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export interface PluginOptions {
module?: VueI18nModule
dropMessageCompiler?: boolean
runtimeOnly?: boolean
compositionOnly?: boolean
ssr?: boolean
fullInstall?: boolean
forceStringify?: boolean
Expand Down
2 changes: 0 additions & 2 deletions packages/unplugin-vue-i18n/test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,6 @@ export async function bundleAndRun(
? options.globalSFCScope
: undefined
options.sourcemap = isBoolean(options.sourcemap) || false
options.bridge = isBoolean(options.bridge) || false
options.legacy = isBoolean(options.legacy) || false
options.vueVersion = isString(options.vueVersion)
? options.vueVersion
: 'v2.6'
Expand Down