From 1653f7992c82a629d2e3f88ddca56976da77dece Mon Sep 17 00:00:00 2001 From: babu-ch Date: Thu, 20 Feb 2025 12:52:01 +0900 Subject: [PATCH 1/9] support v12: mjs to js --- packages/unplugin-vue-i18n/src/core/resource.ts | 2 +- .../test/webpack/__snapshots__/sourcemap.test.ts.snap | 8 ++++---- packages/vite-plugin-vue-i18n/src/index.ts | 10 +++++----- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/unplugin-vue-i18n/src/core/resource.ts b/packages/unplugin-vue-i18n/src/core/resource.ts index 94426d62..203e7dbb 100644 --- a/packages/unplugin-vue-i18n/src/core/resource.ts +++ b/packages/unplugin-vue-i18n/src/core/resource.ts @@ -68,7 +68,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 diff --git a/packages/unplugin-vue-i18n/test/webpack/__snapshots__/sourcemap.test.ts.snap b/packages/unplugin-vue-i18n/test/webpack/__snapshots__/sourcemap.test.ts.snap index b09a4297..da65e63e 100644 --- a/packages/unplugin-vue-i18n/test/webpack/__snapshots__/sourcemap.test.ts.snap +++ b/packages/unplugin-vue-i18n/test/webpack/__snapshots__/sourcemap.test.ts.snap @@ -1,12 +1,12 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`custom blocks: json 1`] = `";;;;;;;;;;AAAa;AACb,8CAA6C,EAAE,aAAa,EAAC;AAC7D;AACA;AACA,kBAAe;AACf;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AEVkE;AAClE;AACA;AACA,CAAuE;AACvE,WAAW,yFAAM,iBAAiB,6FAAM;;;AAGxC,CAAgO;AAChO,iCAAiC,2OAAe,oBAAoB,4EAAM;AAC1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QAAQ,gCAAgC,kBAAkB,EAAE,mCAAmC,SAAS,+BAA+B,QAAQ,kCAAkC,cAAc,EAAE,oCAAoC,SAAS,iCAAiC,QAAQ,kCAAkC,aAAa;AACrrB,GAAG;AACH;AACA,KAAK,kCAAkC,SAAS,+BAA+B,QAAQ,+BAA+B,kBAAkB,SAAS,kCAAkC,SAAS,+BAA+B,QAAQ,gCAAgC,WAAW,kCAAkC,SAAS,+BAA+B,QAAQ,iCAAiC,oBAAoB;AACrZ;AACA;AACA,cAAc,kCAAkC,SAAS,+BAA+B,QAAQ,+BAA+B,kBAAkB,SAAS,kCAAkC,SAAS,+BAA+B,QAAQ,gCAAgC,WAAW,kCAAkC,SAAS,+BAA+B,QAAQ,iCAAiC;AAC1Y;AACA;AACA;AACA,iEAAe;;;;;;UCbf;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;;WCtBA;WACA;WACA;WACA;WACA,yCAAyC,wCAAwC;WACjF;WACA;WACA;;;;;WCPA;;;;;WCAA;WACA;WACA;WACA,uDAAuD,iBAAiB;WACxE;WACA,gDAAgD,aAAa;WAC7D;;;;;;;;;;;;;ACN+B;AACG;;AAElC;AACA,kBAAkB,+CAAS;AAC3B,mBAAmB,oCAAO;AAC1B;;AAEA,iEAAe,+CAAS"`; diff --git a/packages/vite-plugin-vue-i18n/src/index.ts b/packages/vite-plugin-vue-i18n/src/index.ts index ddc19322..a895697e 100644 --- a/packages/vite-plugin-vue-i18n/src/index.ts +++ b/packages/vite-plugin-vue-i18n/src/index.ts @@ -94,7 +94,7 @@ function pluginI18n( : `${installedPkg}` const runtimeModule = `${ installedVueI18nBridge ? 'vue-i18n-bridge' : installedPkg - }.runtime.mjs` + }.runtime.js` const forceStringify = !!options.forceStringify let isProduction = false @@ -136,12 +136,12 @@ function pluginI18n( if (isArray(config.resolve!.alias)) { config.resolve!.alias.push({ find: 'vue-i18n', - replacement: `petite-vue-i18n/dist/petite-vue-i18n.mjs` + replacement: `petite-vue-i18n/dist/petite-vue-i18n.js` }) } else { // eslint-disable-next-line @typescript-eslint/no-explicit-any ;(config.resolve!.alias as any)['vue-i18n'] = - `petite-vue-i18n/dist/petite-vue-i18n.mjs` + `petite-vue-i18n/dist/petite-vue-i18n.js` } debug(`alias name: ${getAliasName()}`) } @@ -229,8 +229,8 @@ function pluginI18n( * NOTE: * Vue SSR with Vite3 (esm) will be worked on `@vue/server-renderer` with cjs. * This prevents the vue feature flag (`__VUE_PROD_DEVTOOLS__`) - * and the vue-i18n feature flags used in `(petitle)-vue-i18n.runtime.mjs` from being set. - * To work around this problem, proxy using the virutal module of vite (rollup) + * and the vue-i18n feature flags used in `(petite)-vue-i18n.runtime.js` from being set. + * To work around this problem, proxy using the virtual module of vite (rollup) */ if (options?.ssr) { if (getVirtualId(id) === INTLIFY_FEATURE_FLAGS_ID) { From 74d8fc8f9bc3c49f404c4b47f7c7f77536957ff7 Mon Sep 17 00:00:00 2001 From: babu-ch Date: Thu, 20 Feb 2025 13:08:49 +0900 Subject: [PATCH 2/9] support v12: remove legacy --- .gitignore | 1 - .prettierignore | 1 - examples/vite/src/main.ts | 1 - examples/webpack/src/main.js | 1 - packages/bundle-utils/src/codegen.ts | 1 - .../e2e/example.test.js | 25 ------------- .../examples/composition/main.js | 1 - .../examples/global/main.js | 1 - .../examples/legacy/App.vue | 35 ------------------- .../examples/legacy/Banana.vue | 19 ---------- .../examples/legacy/index.html | 13 ------- .../examples/legacy/locales/en.yaml | 3 -- .../examples/legacy/locales/ja.json | 6 ---- .../examples/legacy/main.js | 20 ----------- packages/rollup-plugin-vue-i18n/package.json | 2 -- .../unplugin-vue-i18n/src/core/options.ts | 8 ----- .../unplugin-vue-i18n/src/core/resource.ts | 4 --- packages/unplugin-vue-i18n/src/types.ts | 1 - packages/unplugin-vue-i18n/test/utils.ts | 1 - .../vite-plugin-vue-i18n/e2e/legacy.test.js | 26 -------------- .../examples/composition/main.ts | 1 - .../examples/composition/vite.config.ts | 3 +- .../examples/global/main.ts | 1 - .../examples/global/vite.config.ts | 7 +--- .../examples/legacy/App.vue | 35 ------------------- .../examples/legacy/Banana.vue | 19 ---------- .../examples/legacy/index.html | 11 ------ .../examples/legacy/locales/en.yaml | 3 -- .../examples/legacy/locales/ja.json | 6 ---- .../examples/legacy/main.ts | 19 ---------- .../examples/legacy/vite.config.ts | 14 -------- .../examples/vite.config.ts | 6 ++-- packages/vite-plugin-vue-i18n/package.json | 1 - packages/vite-plugin-vue-i18n/src/index.ts | 11 ------ packages/vite-plugin-vue-i18n/src/options.ts | 1 - packages/vue-i18n-loader/e2e/legacy.test.js | 26 -------------- .../examples/composition/main.js | 1 - .../vue-i18n-loader/examples/global/main.js | 1 - .../vue-i18n-loader/examples/legacy/App.vue | 35 ------------------- .../examples/legacy/Banana.vue | 19 ---------- .../examples/legacy/index.html | 13 ------- .../examples/legacy/locales/en.yaml | 3 -- .../examples/legacy/locales/ja.json | 6 ---- .../vue-i18n-loader/examples/legacy/main.js | 20 ----------- .../examples/webpack.config.js | 6 +--- packages/vue-i18n-loader/src/index.ts | 12 ++----- packages/vue-i18n-loader/src/options.ts | 1 - 47 files changed, 7 insertions(+), 444 deletions(-) delete mode 100644 packages/rollup-plugin-vue-i18n/examples/legacy/App.vue delete mode 100644 packages/rollup-plugin-vue-i18n/examples/legacy/Banana.vue delete mode 100644 packages/rollup-plugin-vue-i18n/examples/legacy/index.html delete mode 100644 packages/rollup-plugin-vue-i18n/examples/legacy/locales/en.yaml delete mode 100644 packages/rollup-plugin-vue-i18n/examples/legacy/locales/ja.json delete mode 100644 packages/rollup-plugin-vue-i18n/examples/legacy/main.js delete mode 100644 packages/vite-plugin-vue-i18n/e2e/legacy.test.js delete mode 100644 packages/vite-plugin-vue-i18n/examples/legacy/App.vue delete mode 100644 packages/vite-plugin-vue-i18n/examples/legacy/Banana.vue delete mode 100644 packages/vite-plugin-vue-i18n/examples/legacy/index.html delete mode 100644 packages/vite-plugin-vue-i18n/examples/legacy/locales/en.yaml delete mode 100644 packages/vite-plugin-vue-i18n/examples/legacy/locales/ja.json delete mode 100644 packages/vite-plugin-vue-i18n/examples/legacy/main.ts delete mode 100644 packages/vite-plugin-vue-i18n/examples/legacy/vite.config.ts delete mode 100644 packages/vue-i18n-loader/e2e/legacy.test.js delete mode 100644 packages/vue-i18n-loader/examples/legacy/App.vue delete mode 100644 packages/vue-i18n-loader/examples/legacy/Banana.vue delete mode 100644 packages/vue-i18n-loader/examples/legacy/index.html delete mode 100644 packages/vue-i18n-loader/examples/legacy/locales/en.yaml delete mode 100644 packages/vue-i18n-loader/examples/legacy/locales/ja.json delete mode 100644 packages/vue-i18n-loader/examples/legacy/main.js diff --git a/.gitignore b/.gitignore index 4fe59f35..565b3a21 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/.prettierignore b/.prettierignore index b546190d..76391e3c 100644 --- a/.prettierignore +++ b/.prettierignore @@ -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 diff --git a/examples/vite/src/main.ts b/examples/vite/src/main.ts index 2d4d83ce..cae3b4c8 100644 --- a/examples/vite/src/main.ts +++ b/examples/vite/src/main.ts @@ -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 }) diff --git a/examples/webpack/src/main.js b/examples/webpack/src/main.js index f7028a77..621e22bc 100644 --- a/examples/webpack/src/main.js +++ b/examples/webpack/src/main.js @@ -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, diff --git a/packages/bundle-utils/src/codegen.ts b/packages/bundle-utils/src/codegen.ts index b332a6a3..4df2a48b 100644 --- a/packages/bundle-utils/src/codegen.ts +++ b/packages/bundle-utils/src/codegen.ts @@ -44,7 +44,6 @@ export interface SourceLocationable { */ export interface CodeGenOptions { type?: 'plain' | 'sfc' | 'bare' - legacy?: boolean bridge?: boolean exportESM?: boolean onlyLocales?: string[] diff --git a/packages/rollup-plugin-vue-i18n/e2e/example.test.js b/packages/rollup-plugin-vue-i18n/e2e/example.test.js index ab79ec86..cc8c6e8e 100644 --- a/packages/rollup-plugin-vue-i18n/e2e/example.test.js +++ b/packages/rollup-plugin-vue-i18n/e2e/example.test.js @@ -21,31 +21,6 @@ describe('composition', () => { }) }) -describe('legacy', () => { - beforeAll(async () => { - await page.goto(`http://localhost:8080/legacy/`) - }) - - test('initial rendering', async () => { - await expect(page).toMatch('言語') - await expect(page).toMatch('こんにちは、世界!') - await expect(page).toMatch('バナナが欲しい?') - }) - - test('change select', async () => { - await page.select('#fruits select', '2') - await expect(page).toMatch('バナナ 2 個') - }) - - test('change locale', async () => { - await page.select('#app select', 'en') - await expect(page).toMatch('Language') - await expect(page).toMatch('hello, world!') - await expect(page).toMatch('Do you want banana?') - await expect(page).toMatch('2 bananas') - }) -}) - describe('global', () => { beforeAll(async () => { await page.goto(`http://localhost:8080/global/`) diff --git a/packages/rollup-plugin-vue-i18n/examples/composition/main.js b/packages/rollup-plugin-vue-i18n/examples/composition/main.js index f33acd09..e28b6f3a 100644 --- a/packages/rollup-plugin-vue-i18n/examples/composition/main.js +++ b/packages/rollup-plugin-vue-i18n/examples/composition/main.js @@ -6,7 +6,6 @@ import ja from './locales/ja.json5' import en from './locales/en.yaml' const i18n = createI18n({ - legacy: false, locale: 'ja', messages: { en, diff --git a/packages/rollup-plugin-vue-i18n/examples/global/main.js b/packages/rollup-plugin-vue-i18n/examples/global/main.js index 35db3fb8..c6ecba45 100644 --- a/packages/rollup-plugin-vue-i18n/examples/global/main.js +++ b/packages/rollup-plugin-vue-i18n/examples/global/main.js @@ -3,7 +3,6 @@ import { createI18n } from 'vue-i18n' import App from './App.vue' const i18n = createI18n({ - legacy: false, locale: 'ja', messages: {} }) diff --git a/packages/rollup-plugin-vue-i18n/examples/legacy/App.vue b/packages/rollup-plugin-vue-i18n/examples/legacy/App.vue deleted file mode 100644 index 6f523ad1..00000000 --- a/packages/rollup-plugin-vue-i18n/examples/legacy/App.vue +++ /dev/null @@ -1,35 +0,0 @@ - - - - - -{ - "en": { - "language": "Language", - "hello": "hello, world!" - }, - "ja": { - "language": "言語", - "hello": "こんにちは、世界!" - } -} - diff --git a/packages/rollup-plugin-vue-i18n/examples/legacy/Banana.vue b/packages/rollup-plugin-vue-i18n/examples/legacy/Banana.vue deleted file mode 100644 index 289946aa..00000000 --- a/packages/rollup-plugin-vue-i18n/examples/legacy/Banana.vue +++ /dev/null @@ -1,19 +0,0 @@ - - - diff --git a/packages/rollup-plugin-vue-i18n/examples/legacy/index.html b/packages/rollup-plugin-vue-i18n/examples/legacy/index.html deleted file mode 100644 index 7ce255f0..00000000 --- a/packages/rollup-plugin-vue-i18n/examples/legacy/index.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - rollup-plugin-vue-i18n composable example - - -
- -
- - - diff --git a/packages/rollup-plugin-vue-i18n/examples/legacy/locales/en.yaml b/packages/rollup-plugin-vue-i18n/examples/legacy/locales/en.yaml deleted file mode 100644 index 85d055d8..00000000 --- a/packages/rollup-plugin-vue-i18n/examples/legacy/locales/en.yaml +++ /dev/null @@ -1,3 +0,0 @@ -select: Do you want banana? -fruits: - banana: 'no bananas | {n} banana | {n} bananas' diff --git a/packages/rollup-plugin-vue-i18n/examples/legacy/locales/ja.json b/packages/rollup-plugin-vue-i18n/examples/legacy/locales/ja.json deleted file mode 100644 index df96dc6f..00000000 --- a/packages/rollup-plugin-vue-i18n/examples/legacy/locales/ja.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "select": "バナナが欲しい?", - "fruits": { - "banana": "バナナがない | バナナ {n} 個" - } -} diff --git a/packages/rollup-plugin-vue-i18n/examples/legacy/main.js b/packages/rollup-plugin-vue-i18n/examples/legacy/main.js deleted file mode 100644 index 9a92e175..00000000 --- a/packages/rollup-plugin-vue-i18n/examples/legacy/main.js +++ /dev/null @@ -1,20 +0,0 @@ -import { createApp } from 'vue' -import { createI18n } from 'vue-i18n' -import App from './App.vue' - -import ja from './locales/ja.json' -import en from './locales/en.yaml' - -const i18n = createI18n({ - legacy: true, - locale: 'ja', - messages: { - en, - ja - } -}) - -const app = createApp(App) - -app.use(i18n) -app.mount('#app') diff --git a/packages/rollup-plugin-vue-i18n/package.json b/packages/rollup-plugin-vue-i18n/package.json index 558e0ab6..e995e851 100644 --- a/packages/rollup-plugin-vue-i18n/package.json +++ b/packages/rollup-plugin-vue-i18n/package.json @@ -62,12 +62,10 @@ "build:example": "yarn build && npm-run-all --parallel \"build:example:*\"", "build:example:composition": "rollup -c ./examples/rollup.config.js --environment BUILD:composition", "build:example:global": "rollup -c ./examples/rollup.config.js --environment BUILD:global", - "build:example:legacy": "rollup -c ./examples/rollup.config.js --environment BUILD:legacy", "clean": "npm-run-all \"clean:*\"", "clean:example": "npm-run-all \"clean:example:*\"", "clean:example:composition": "rm -rf ./examples/composition/index.js", "clean:example:global": "rm -rf ./examples/global/index.js", - "clean:example:legacy": "rm -rf ./examples/legacy/index.js", "clean:lib": "rm -rf ./lib", "test": "yarn test:e2e", "test:e2e": "yarn build:example && jest --runInBand --config ./jest.e2e.config.js", diff --git a/packages/unplugin-vue-i18n/src/core/options.ts b/packages/unplugin-vue-i18n/src/core/options.ts index 1a76615a..8fafedc6 100644 --- a/packages/unplugin-vue-i18n/src/core/options.ts +++ b/packages/unplugin-vue-i18n/src/core/options.ts @@ -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) @@ -90,7 +83,6 @@ export function resolveOptions(options: PluginOptions) { globalSFCScope, runtimeOnly, dropMessageCompiler, - compositionOnly, fullInstall, ssrBuild, allowDynamic, diff --git a/packages/unplugin-vue-i18n/src/core/resource.ts b/packages/unplugin-vue-i18n/src/core/resource.ts index 203e7dbb..a90364d4 100644 --- a/packages/unplugin-vue-i18n/src/core/resource.ts +++ b/packages/unplugin-vue-i18n/src/core/resource.ts @@ -55,7 +55,6 @@ export function resourcePlugin( globalSFCScope, runtimeOnly, dropMessageCompiler, - compositionOnly, fullInstall, ssrBuild, strictMessage, @@ -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 @@ -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') diff --git a/packages/unplugin-vue-i18n/src/types.ts b/packages/unplugin-vue-i18n/src/types.ts index 5b8276d5..a8a139da 100644 --- a/packages/unplugin-vue-i18n/src/types.ts +++ b/packages/unplugin-vue-i18n/src/types.ts @@ -8,7 +8,6 @@ export interface PluginOptions { module?: VueI18nModule dropMessageCompiler?: boolean runtimeOnly?: boolean - compositionOnly?: boolean ssr?: boolean fullInstall?: boolean forceStringify?: boolean diff --git a/packages/unplugin-vue-i18n/test/utils.ts b/packages/unplugin-vue-i18n/test/utils.ts index 8780a6db..2b425b59 100644 --- a/packages/unplugin-vue-i18n/test/utils.ts +++ b/packages/unplugin-vue-i18n/test/utils.ts @@ -174,7 +174,6 @@ export async function bundleAndRun( : 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' diff --git a/packages/vite-plugin-vue-i18n/e2e/legacy.test.js b/packages/vite-plugin-vue-i18n/e2e/legacy.test.js deleted file mode 100644 index 8cfe1f8e..00000000 --- a/packages/vite-plugin-vue-i18n/e2e/legacy.test.js +++ /dev/null @@ -1,26 +0,0 @@ -describe('legacy', () => { - beforeAll(async () => { - await page.goto(`http://localhost:8080/legacy/`) - }) - - test('initial rendering', async () => { - await expect(page).toMatch('言語') - await expect(page).toMatch('こんにちは、世界!') - await expect(page).toMatch('バナナが欲しい?') - await expect(page).toMatch('バナナ 0 個') - }) - - test('change locale', async () => { - await page.select('#app select', 'en') - await expect(page).toMatch('Language') - await expect(page).toMatch('hello, world!') - await expect(page).toMatch('no bananas') - }) - - test('change banana select', async () => { - await page.select('#fruits select', '3') - await expect(page).toMatch('3 bananas') - await page.select('#app select', 'ja') - await expect(page).toMatch('バナナ 3 個') - }) -}) diff --git a/packages/vite-plugin-vue-i18n/examples/composition/main.ts b/packages/vite-plugin-vue-i18n/examples/composition/main.ts index 94e1ec70..1c1397ff 100644 --- a/packages/vite-plugin-vue-i18n/examples/composition/main.ts +++ b/packages/vite-plugin-vue-i18n/examples/composition/main.ts @@ -4,7 +4,6 @@ import App from './App.vue' import messages from '@intlify/vite-plugin-vue-i18n/messages' const i18n = createI18n({ - legacy: false, locale: 'ja', messages }) diff --git a/packages/vite-plugin-vue-i18n/examples/composition/vite.config.ts b/packages/vite-plugin-vue-i18n/examples/composition/vite.config.ts index fae599ad..acc30e30 100644 --- a/packages/vite-plugin-vue-i18n/examples/composition/vite.config.ts +++ b/packages/vite-plugin-vue-i18n/examples/composition/vite.config.ts @@ -7,8 +7,7 @@ export default defineConfig({ plugins: [ vue(), vueI18n({ - include: path.resolve(__dirname, './locales/**'), - compositionOnly: true + include: path.resolve(__dirname, './locales/**') }) ] }) diff --git a/packages/vite-plugin-vue-i18n/examples/global/main.ts b/packages/vite-plugin-vue-i18n/examples/global/main.ts index 1981ee31..fa935eab 100644 --- a/packages/vite-plugin-vue-i18n/examples/global/main.ts +++ b/packages/vite-plugin-vue-i18n/examples/global/main.ts @@ -3,7 +3,6 @@ import { createI18n } from 'vue-i18n' import App from './App.vue' const i18n = createI18n({ - legacy: false, locale: 'ja' }) diff --git a/packages/vite-plugin-vue-i18n/examples/global/vite.config.ts b/packages/vite-plugin-vue-i18n/examples/global/vite.config.ts index 19cc7848..817c8827 100644 --- a/packages/vite-plugin-vue-i18n/examples/global/vite.config.ts +++ b/packages/vite-plugin-vue-i18n/examples/global/vite.config.ts @@ -3,10 +3,5 @@ import vue from '@vitejs/plugin-vue' import vueI18n from '../../src/index' export default defineConfig({ - plugins: [ - vue(), - vueI18n({ - compositionOnly: true - }) - ] + plugins: [vue(), vueI18n({})] }) diff --git a/packages/vite-plugin-vue-i18n/examples/legacy/App.vue b/packages/vite-plugin-vue-i18n/examples/legacy/App.vue deleted file mode 100644 index 6f523ad1..00000000 --- a/packages/vite-plugin-vue-i18n/examples/legacy/App.vue +++ /dev/null @@ -1,35 +0,0 @@ - - - - - -{ - "en": { - "language": "Language", - "hello": "hello, world!" - }, - "ja": { - "language": "言語", - "hello": "こんにちは、世界!" - } -} - diff --git a/packages/vite-plugin-vue-i18n/examples/legacy/Banana.vue b/packages/vite-plugin-vue-i18n/examples/legacy/Banana.vue deleted file mode 100644 index 289946aa..00000000 --- a/packages/vite-plugin-vue-i18n/examples/legacy/Banana.vue +++ /dev/null @@ -1,19 +0,0 @@ - - - diff --git a/packages/vite-plugin-vue-i18n/examples/legacy/index.html b/packages/vite-plugin-vue-i18n/examples/legacy/index.html deleted file mode 100644 index efaeb43f..00000000 --- a/packages/vite-plugin-vue-i18n/examples/legacy/index.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - vite-plugin-vue-i18n legacy example - - -
- - - diff --git a/packages/vite-plugin-vue-i18n/examples/legacy/locales/en.yaml b/packages/vite-plugin-vue-i18n/examples/legacy/locales/en.yaml deleted file mode 100644 index 85d055d8..00000000 --- a/packages/vite-plugin-vue-i18n/examples/legacy/locales/en.yaml +++ /dev/null @@ -1,3 +0,0 @@ -select: Do you want banana? -fruits: - banana: 'no bananas | {n} banana | {n} bananas' diff --git a/packages/vite-plugin-vue-i18n/examples/legacy/locales/ja.json b/packages/vite-plugin-vue-i18n/examples/legacy/locales/ja.json deleted file mode 100644 index df96dc6f..00000000 --- a/packages/vite-plugin-vue-i18n/examples/legacy/locales/ja.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "select": "バナナが欲しい?", - "fruits": { - "banana": "バナナがない | バナナ {n} 個" - } -} diff --git a/packages/vite-plugin-vue-i18n/examples/legacy/main.ts b/packages/vite-plugin-vue-i18n/examples/legacy/main.ts deleted file mode 100644 index 0f96f596..00000000 --- a/packages/vite-plugin-vue-i18n/examples/legacy/main.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { createApp } from 'vue' -import { createI18n } from 'vue-i18n' -import App from './App.vue' -import en from './locales/en.yaml' -import ja from './locales/ja.json' - -const i18n = createI18n({ - legacy: true, - locale: 'ja', - messages: { - en, - ja - } -}) - -const app = createApp(App) - -app.use(i18n) -app.mount('#app') diff --git a/packages/vite-plugin-vue-i18n/examples/legacy/vite.config.ts b/packages/vite-plugin-vue-i18n/examples/legacy/vite.config.ts deleted file mode 100644 index 7166e2b2..00000000 --- a/packages/vite-plugin-vue-i18n/examples/legacy/vite.config.ts +++ /dev/null @@ -1,14 +0,0 @@ -import path from 'path' -import { defineConfig } from 'vite' -import vue from '@vitejs/plugin-vue' -import vueI18n from '../../src/index' - -export default defineConfig({ - plugins: [ - vue(), - vueI18n({ - include: path.resolve(__dirname, './locales/**'), - compositionOnly: false - }) - ] -}) diff --git a/packages/vite-plugin-vue-i18n/examples/vite.config.ts b/packages/vite-plugin-vue-i18n/examples/vite.config.ts index d77515ed..9fb54527 100644 --- a/packages/vite-plugin-vue-i18n/examples/vite.config.ts +++ b/packages/vite-plugin-vue-i18n/examples/vite.config.ts @@ -16,16 +16,14 @@ export default defineConfig({ rollupOptions: { input: { composition: path.resolve(__dirname, './composition/index.html'), - global: path.resolve(__dirname, './global/index.html'), - legacy: path.resolve(__dirname, './legacy/index.html') + global: path.resolve(__dirname, './global/index.html') } } }, plugins: [ vue(), vueI18n({ - include: path.resolve(__dirname, './**/locales/**'), - compositionOnly: false + include: path.resolve(__dirname, './**/locales/**') }) ] }) diff --git a/packages/vite-plugin-vue-i18n/package.json b/packages/vite-plugin-vue-i18n/package.json index bcd45cd8..0cfc39bd 100644 --- a/packages/vite-plugin-vue-i18n/package.json +++ b/packages/vite-plugin-vue-i18n/package.json @@ -84,7 +84,6 @@ "dev": "vite examples --config ./examples/vite.config.ts", "dev:composition": "vite examples/composition --config ./examples/composition/vite.config.ts", "dev:global": "vite examples/global --config ./examples/global/vite.config.ts", - "dev:legacy": "vite examples/legacy --config ./examples/legacy/vite.config.ts", "test": "yarn test:e2e", "test:e2e": "jest --runInBand --config ./jest.e2e.config.js", "watch": "tsc -p . --watch", diff --git a/packages/vite-plugin-vue-i18n/src/index.ts b/packages/vite-plugin-vue-i18n/src/index.ts index a895697e..f40b856e 100644 --- a/packages/vite-plugin-vue-i18n/src/index.ts +++ b/packages/vite-plugin-vue-i18n/src/index.ts @@ -63,12 +63,6 @@ function pluginI18n( ? options.runtimeOnly : true // prettier-ignore - const compositionOnly = installedPkg === 'vue-i18n' - ? isBoolean(options.compositionOnly) - ? options.compositionOnly - : true - : true - // prettier-ignore const fullInstall = installedPkg === 'vue-i18n' ? isBoolean(options.fullInstall) ? options.fullInstall @@ -147,10 +141,6 @@ function pluginI18n( } config.define = config.define || {} - config.define['__VUE_I18N_LEGACY_API__'] = !compositionOnly - debug( - `set __VUE_I18N_LEGACY_API__ is '${config.define['__VUE_I18N_LEGACY_API__']}'` - ) config.define['__VUE_I18N_FULL_INSTALL__'] = fullInstall debug( @@ -235,7 +225,6 @@ function pluginI18n( if (options?.ssr) { if (getVirtualId(id) === INTLIFY_FEATURE_FLAGS_ID) { return `import { getGlobalThis } from '@intlify/shared'; -getGlobalThis().__VUE_I18N_LEGACY_API__ = ${JSON.stringify(!compositionOnly)}; getGlobalThis().__VUE_I18N_FULL_INSTALL__ = ${JSON.stringify(fullInstall)}; getGlobalThis().__VUE_I18N_PROD_DEVTOOLS__ = false; getGlobalThis().__VUE_PROD_DEVTOOLS__ = false; diff --git a/packages/vite-plugin-vue-i18n/src/options.ts b/packages/vite-plugin-vue-i18n/src/options.ts index 86886eb6..ca39d7b6 100644 --- a/packages/vite-plugin-vue-i18n/src/options.ts +++ b/packages/vite-plugin-vue-i18n/src/options.ts @@ -1,7 +1,6 @@ export type VitePluginVueI18nOptions = { forceStringify?: boolean runtimeOnly?: boolean - compositionOnly?: boolean fullInstall?: boolean include?: string | string[] defaultSFCLang?: 'json' | 'json5' | 'yml' | 'yaml' diff --git a/packages/vue-i18n-loader/e2e/legacy.test.js b/packages/vue-i18n-loader/e2e/legacy.test.js deleted file mode 100644 index 8cfe1f8e..00000000 --- a/packages/vue-i18n-loader/e2e/legacy.test.js +++ /dev/null @@ -1,26 +0,0 @@ -describe('legacy', () => { - beforeAll(async () => { - await page.goto(`http://localhost:8080/legacy/`) - }) - - test('initial rendering', async () => { - await expect(page).toMatch('言語') - await expect(page).toMatch('こんにちは、世界!') - await expect(page).toMatch('バナナが欲しい?') - await expect(page).toMatch('バナナ 0 個') - }) - - test('change locale', async () => { - await page.select('#app select', 'en') - await expect(page).toMatch('Language') - await expect(page).toMatch('hello, world!') - await expect(page).toMatch('no bananas') - }) - - test('change banana select', async () => { - await page.select('#fruits select', '3') - await expect(page).toMatch('3 bananas') - await page.select('#app select', 'ja') - await expect(page).toMatch('バナナ 3 個') - }) -}) diff --git a/packages/vue-i18n-loader/examples/composition/main.js b/packages/vue-i18n-loader/examples/composition/main.js index f7028a77..621e22bc 100644 --- a/packages/vue-i18n-loader/examples/composition/main.js +++ b/packages/vue-i18n-loader/examples/composition/main.js @@ -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, diff --git a/packages/vue-i18n-loader/examples/global/main.js b/packages/vue-i18n-loader/examples/global/main.js index da0524ca..fce949a5 100644 --- a/packages/vue-i18n-loader/examples/global/main.js +++ b/packages/vue-i18n-loader/examples/global/main.js @@ -3,7 +3,6 @@ import { createI18n } from 'vue-i18n' import App from './App.vue' const i18n = createI18n({ - legacy: false, locale: 'ja', messages: { en: { diff --git a/packages/vue-i18n-loader/examples/legacy/App.vue b/packages/vue-i18n-loader/examples/legacy/App.vue deleted file mode 100644 index 6f523ad1..00000000 --- a/packages/vue-i18n-loader/examples/legacy/App.vue +++ /dev/null @@ -1,35 +0,0 @@ - - - - - -{ - "en": { - "language": "Language", - "hello": "hello, world!" - }, - "ja": { - "language": "言語", - "hello": "こんにちは、世界!" - } -} - diff --git a/packages/vue-i18n-loader/examples/legacy/Banana.vue b/packages/vue-i18n-loader/examples/legacy/Banana.vue deleted file mode 100644 index 289946aa..00000000 --- a/packages/vue-i18n-loader/examples/legacy/Banana.vue +++ /dev/null @@ -1,19 +0,0 @@ - - - diff --git a/packages/vue-i18n-loader/examples/legacy/index.html b/packages/vue-i18n-loader/examples/legacy/index.html deleted file mode 100644 index 1e74d441..00000000 --- a/packages/vue-i18n-loader/examples/legacy/index.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - vue-i18n-loader example - - -
- -
- - - diff --git a/packages/vue-i18n-loader/examples/legacy/locales/en.yaml b/packages/vue-i18n-loader/examples/legacy/locales/en.yaml deleted file mode 100644 index 85d055d8..00000000 --- a/packages/vue-i18n-loader/examples/legacy/locales/en.yaml +++ /dev/null @@ -1,3 +0,0 @@ -select: Do you want banana? -fruits: - banana: 'no bananas | {n} banana | {n} bananas' diff --git a/packages/vue-i18n-loader/examples/legacy/locales/ja.json b/packages/vue-i18n-loader/examples/legacy/locales/ja.json deleted file mode 100644 index df96dc6f..00000000 --- a/packages/vue-i18n-loader/examples/legacy/locales/ja.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "select": "バナナが欲しい?", - "fruits": { - "banana": "バナナがない | バナナ {n} 個" - } -} diff --git a/packages/vue-i18n-loader/examples/legacy/main.js b/packages/vue-i18n-loader/examples/legacy/main.js deleted file mode 100644 index 9a92e175..00000000 --- a/packages/vue-i18n-loader/examples/legacy/main.js +++ /dev/null @@ -1,20 +0,0 @@ -import { createApp } from 'vue' -import { createI18n } from 'vue-i18n' -import App from './App.vue' - -import ja from './locales/ja.json' -import en from './locales/en.yaml' - -const i18n = createI18n({ - legacy: true, - locale: 'ja', - messages: { - en, - ja - } -}) - -const app = createApp(App) - -app.use(i18n) -app.mount('#app') diff --git a/packages/vue-i18n-loader/examples/webpack.config.js b/packages/vue-i18n-loader/examples/webpack.config.js index ee366b5e..cc48864f 100644 --- a/packages/vue-i18n-loader/examples/webpack.config.js +++ b/packages/vue-i18n-loader/examples/webpack.config.js @@ -6,7 +6,6 @@ module.exports = { devtool: 'source-map', entry: { composition: path.resolve(__dirname, './composition/main.js'), - legacy: path.resolve(__dirname, './legacy/main.js'), global: path.resolve(__dirname, './global/main.js') }, output: { @@ -41,10 +40,7 @@ module.exports = { test: /\.(json5?|ya?ml)$/, // target json, json5, yaml and yml files type: 'javascript/auto', // Use `Rule.include` to specify the files of locale messages to be pre-compiled - include: [ - path.resolve(__dirname, './composition/locales'), - path.resolve(__dirname, './legacy/locales') - ], + include: [path.resolve(__dirname, './composition/locales')], use: [ { loader: path.resolve(__dirname, '../lib/index.js'), diff --git a/packages/vue-i18n-loader/src/index.ts b/packages/vue-i18n-loader/src/index.ts index 55b3f48b..4b1b80eb 100644 --- a/packages/vue-i18n-loader/src/index.ts +++ b/packages/vue-i18n-loader/src/index.ts @@ -6,7 +6,6 @@ import { parse, ParsedUrlQuery } from 'querystring' import { RawSourceMap } from 'source-map' import { isEmptyObject, isString } from '@intlify/shared' import { generateJSON, generateYAML } from '@intlify/bundle-utils' -import { createBridgeCodeGenerator } from './legacy' import type { CodeGenOptions, DevEnv } from '@intlify/bundle-utils' import type { VueI18nLoaderOptions } from './options' @@ -18,8 +17,6 @@ const loader: LoaderDefinitionFunction = function ( sourceMap: RawSourceMap | undefined ): void { const loaderContext = this // eslint-disable-line @typescript-eslint/no-this-alias - const loaderOptions = loaderUtils.getOptions(loaderContext as any) || {} - const { bridge } = loaderOptions as VueI18nLoaderOptions const query = parse(loaderContext.resourceQuery) const options = getOptions(loaderContext, query, sourceMap) as CodeGenOptions @@ -43,11 +40,7 @@ const loader: LoaderDefinitionFunction = function ( // }) // } const generate = /json5?/.test(langInfo) ? generateJSON : generateYAML - const { code, map } = generate( - source, - options, - bridge ? createBridgeCodeGenerator(source, query) : undefined - ) + const { code, map } = generate(source, options) // console.log('code', code) this.callback(null, code, map as any) } catch (err: any) { @@ -63,12 +56,11 @@ function getOptions( ): Record { const loaderOptions = loaderUtils.getOptions(loaderContext) || {} const { resourcePath: filename, mode } = loaderContext - const { forceStringify, productionSourceMap, bridge, useClassComponent } = + const { forceStringify, productionSourceMap, useClassComponent } = loaderOptions as VueI18nLoaderOptions const baseOptions = { filename, - bridge, sourceMap: productionSourceMap || false, inSourceMap, forceStringify, diff --git a/packages/vue-i18n-loader/src/options.ts b/packages/vue-i18n-loader/src/options.ts index d065f608..725924ed 100644 --- a/packages/vue-i18n-loader/src/options.ts +++ b/packages/vue-i18n-loader/src/options.ts @@ -1,6 +1,5 @@ export type VueI18nLoaderOptions = { forceStringify?: boolean productionSourceMap?: boolean - bridge?: boolean useClassComponent?: boolean } From 68a8947f346d6f83fce6703aa8a44e885b1d0c62 Mon Sep 17 00:00:00 2001 From: babu-ch Date: Thu, 20 Feb 2025 13:13:53 +0900 Subject: [PATCH 3/9] support v12: update docs --- packages/unplugin-vue-i18n/README.md | 13 ++----------- packages/vite-plugin-vue-i18n/README.md | 20 +++----------------- 2 files changed, 5 insertions(+), 28 deletions(-) diff --git a/packages/unplugin-vue-i18n/README.md b/packages/unplugin-vue-i18n/README.md index 77aa44e7..40cffdf2 100644 --- a/packages/unplugin-vue-i18n/README.md +++ b/packages/unplugin-vue-i18n/README.md @@ -424,15 +424,6 @@ If do you will use this option, you need to enable `jitCompilation` option. For more details, See [here](#-automatic-bundling) -### `compositionOnly` - -- **Type:** `boolean` -- **Default:** `true` - - Whether to make vue-i18n API only composition API. **By default the legacy API is tree-shaken.** - - For more details, See [here](https://vue-i18n.intlify.dev/guide/advanced/optimization.html#reduce-bundle-size-with-feature-build-flags) - ### `fullInstall` - **Type:** `boolean` @@ -440,7 +431,7 @@ If do you will use this option, you need to enable `jitCompilation` option. 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) @@ -614,7 +605,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. diff --git a/packages/vite-plugin-vue-i18n/README.md b/packages/vite-plugin-vue-i18n/README.md index c38d40c9..c0061d36 100644 --- a/packages/vite-plugin-vue-i18n/README.md +++ b/packages/vite-plugin-vue-i18n/README.md @@ -37,9 +37,7 @@ $ yarn add -D @intlify/vite-plugin-vue-i18n ## ⚠️ Notice -When this plugin is installed, Vue I18n can only use the Composition API, and if you want to use the Legacy API, you need to set the `compositionOnly` option to `false`. - -Also, if you do a production build with vite, Vue I18n will automatically bundle the runtime only module. If you need on-demand compilation with Message compiler, you need to set the `runtimeOnly` option to `false`. +If you do a production build with vite, Vue I18n will automatically bundle the runtime only module. If you need on-demand compilation with Message compiler, you need to set the `runtimeOnly` option to `false`. ## 🚀 Usage @@ -64,9 +62,6 @@ export default defineConfig({ plugins: [ vue(), // you need to install `@vitejs/plugin-vue` vueI18n({ - // if you want to use Vue I18n Legacy API, you need to set `compositionOnly: false` - // compositionOnly: false, - // you need to set i18n resource including paths ! include: resolve( dirname(fileURLToPath(import.meta.url)), @@ -270,15 +265,6 @@ About details, See the below section For more details, See [here](#-automatic-bundling) -### `compositionOnly` - -- **Type:** `boolean` -- **Default:** `true` - - Whether to make vue-i18n's API only composition API. **By default the legacy API is tree-shaken.** - - For more details, See [here](https://vue-i18n.intlify.dev/guide/advanced/optimization.html#reduce-bundle-size-with-feature-build-flags) - ### `fullInstall` - **Type:** `boolean` @@ -286,7 +272,7 @@ About details, See the below section 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) @@ -413,7 +399,7 @@ About details, See the below section 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. ## 📜 Changelog From 69221b8e1e2d4bf202625117f7431636b9be9090 Mon Sep 17 00:00:00 2001 From: babu-ch Date: Thu, 20 Feb 2025 15:59:02 +0900 Subject: [PATCH 4/9] support v12: remove bridge --- packages/bundle-utils/src/codegen.ts | 1 - packages/unplugin-vue-i18n/test/utils.ts | 1 - packages/vite-plugin-vue-i18n/src/check.ts | 11 ------ packages/vite-plugin-vue-i18n/src/index.ts | 10 +---- packages/vue-i18n-loader/src/legacy.ts | 38 ------------------- .../__snapshots__/custom-block.test.ts.snap | 38 ------------------- .../vue-i18n-loader/test/custom-block.test.ts | 23 ----------- .../vue-i18n-loader/test/fixtures/compile.vue | 26 ------------- 8 files changed, 2 insertions(+), 146 deletions(-) delete mode 100644 packages/vite-plugin-vue-i18n/src/check.ts delete mode 100644 packages/vue-i18n-loader/src/legacy.ts delete mode 100644 packages/vue-i18n-loader/test/fixtures/compile.vue diff --git a/packages/bundle-utils/src/codegen.ts b/packages/bundle-utils/src/codegen.ts index 4df2a48b..4516a441 100644 --- a/packages/bundle-utils/src/codegen.ts +++ b/packages/bundle-utils/src/codegen.ts @@ -44,7 +44,6 @@ export interface SourceLocationable { */ export interface CodeGenOptions { type?: 'plain' | 'sfc' | 'bare' - bridge?: boolean exportESM?: boolean onlyLocales?: string[] source?: string diff --git a/packages/unplugin-vue-i18n/test/utils.ts b/packages/unplugin-vue-i18n/test/utils.ts index 2b425b59..d832efe9 100644 --- a/packages/unplugin-vue-i18n/test/utils.ts +++ b/packages/unplugin-vue-i18n/test/utils.ts @@ -173,7 +173,6 @@ export async function bundleAndRun( ? options.globalSFCScope : undefined options.sourcemap = isBoolean(options.sourcemap) || false - options.bridge = isBoolean(options.bridge) || false options.vueVersion = isString(options.vueVersion) ? options.vueVersion : 'v2.6' diff --git a/packages/vite-plugin-vue-i18n/src/check.ts b/packages/vite-plugin-vue-i18n/src/check.ts deleted file mode 100644 index cfddb711..00000000 --- a/packages/vite-plugin-vue-i18n/src/check.ts +++ /dev/null @@ -1,11 +0,0 @@ -// eslint-disable-next-line @typescript-eslint/ban-types -export function checkVueI18nBridgeInstallPackage(debug: Function): boolean { - let ret = false - try { - debug(`vue-i18n-bridge load path: ${require.resolve('vue-i18n-bridge')}`) - ret = true - } catch (e) { - debug(`cannot find 'vue-i18n-bridge'`, e) - } - return ret -} diff --git a/packages/vite-plugin-vue-i18n/src/index.ts b/packages/vite-plugin-vue-i18n/src/index.ts index f40b856e..a093e958 100644 --- a/packages/vite-plugin-vue-i18n/src/index.ts +++ b/packages/vite-plugin-vue-i18n/src/index.ts @@ -18,7 +18,6 @@ import createDebug from 'debug' import { normalizePath } from 'vite' import { RawSourceMap } from 'source-map' import { parseVueRequest } from './query' -import { checkVueI18nBridgeInstallPackage } from './check' import type { Plugin, ResolvedConfig, UserConfig } from 'vite' import type { CodeGenOptions, DevEnv } from '@intlify/bundle-utils' @@ -31,7 +30,6 @@ const INTLIFY_FEATURE_FLAGS_ID = '@intlify-feature-flags' const INTLIFY_FEATURE_PROXY_SUFFIX = 'inject-feature-proxy' const installedPkg = checkInstallPackage('@intlify/vite-plugin-vue-i18n', debug) -const installedVueI18nBridge = checkVueI18nBridgeInstallPackage(debug) const VIRTUAL_PREFIX = '\0' @@ -80,15 +78,11 @@ function pluginI18n( } // prettier-ignore const getAliasName = () => - installedVueI18nBridge && installedPkg === 'vue-i18n' - ? 'vue-i18n-bridge' - : installedPkg === 'petite-vue-i18n' && isBoolean(useVueI18nImportName) && + installedPkg === 'petite-vue-i18n' && isBoolean(useVueI18nImportName) && useVueI18nImportName ? 'vue-i18n' : `${installedPkg}` - const runtimeModule = `${ - installedVueI18nBridge ? 'vue-i18n-bridge' : installedPkg - }.runtime.js` + const runtimeModule = `${installedPkg}.runtime.js` const forceStringify = !!options.forceStringify let isProduction = false diff --git a/packages/vue-i18n-loader/src/legacy.ts b/packages/vue-i18n-loader/src/legacy.ts deleted file mode 100644 index 3da31a47..00000000 --- a/packages/vue-i18n-loader/src/legacy.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { ParsedUrlQuery } from 'querystring' -import JSON5 from 'json5' -import yaml from 'js-yaml' - -export function createBridgeCodeGenerator( - source: string | Buffer, - query: ParsedUrlQuery -): () => string { - return () => { - const data = convert(source, query.lang as string) - let value = JSON.parse(data) - - if (query.locale && typeof query.locale === 'string') { - value = Object.assign({}, { [query.locale]: value }) - } - - return JSON.stringify(value) - .replace(/\u2028/g, '\\u2028') - .replace(/\u2029/g, '\\u2029') - .replace(/\\/g, '\\\\') - .replace(/\u0027/g, '\\u0027') - } -} - -function convert(source: string | Buffer, lang: string): string { - const value = Buffer.isBuffer(source) ? source.toString() : source - - switch (lang) { - case 'yaml': - case 'yml': - const data = yaml.load(value) - return JSON.stringify(data, undefined, '\t') - case 'json5': - return JSON.stringify(JSON5.parse(value)) - default: - return value - } -} diff --git a/packages/vue-i18n-loader/test/__snapshots__/custom-block.test.ts.snap b/packages/vue-i18n-loader/test/__snapshots__/custom-block.test.ts.snap index f3018a53..7034a842 100644 --- a/packages/vue-i18n-loader/test/__snapshots__/custom-block.test.ts.snap +++ b/packages/vue-i18n-loader/test/__snapshots__/custom-block.test.ts.snap @@ -31,44 +31,6 @@ Array [ ] `; -exports[`bridge 1`] = ` -Array [ - Object { - "locale": "", - "resource": Object { - "en": Object { - "backslash-backslash": [Function], - "backslash-single-quote": [Function], - "emoji": [Function], - "hello": [Function], - "hi, {name} !": [Function], - "linked": [Function], - "list": [Function], - "literal": [Function], - "named": [Function], - "nest": Object { - "lieteral": [Function], - }, - "plural": [Function], - "single-quote": [Function], - "unicode": [Function], - "unicode-escape": [Function], - "こんにちは": [Function], - }, - "ja": Object { - "hello": [Function], - }, - }, - }, -] -`; - -exports[`bridge 2`] = ` -Array [ - "{\\"en\\":{\\"hello\\":\\"hello world!\\",\\"named\\":\\"hi, {name} !\\",\\"list\\":\\"hi, {0} !\\",\\"literal\\":\\"hi, { 'kazupon' } !\\",\\"linked\\":\\"hi, @:name !\\",\\"plural\\":\\"@.caml:{'no apples'} | {0} apple | {n} apples\\",\\"nest\\":{\\"lieteral\\":\\"hi, kazupon !\\"},\\"hi, {name} !\\":\\"hi hi!\\",\\"こんにちは\\":\\"こんにちは!\\",\\"single-quote\\":\\"I don't know!\\",\\"emoji\\":\\"😺\\",\\"unicode\\":\\"A\\",\\"unicode-escape\\":\\"\\\\\\\\u0041\\",\\"backslash-single-quote\\":\\"\\\\\\\\'\\",\\"backslash-backslash\\":\\"\\\\\\\\\\\\\\\\\\"},\\"ja\\":{\\"hello\\":\\"こんにちは!\\"}}", -] -`; - exports[`global 1`] = ` Array [ Object { diff --git a/packages/vue-i18n-loader/test/custom-block.test.ts b/packages/vue-i18n-loader/test/custom-block.test.ts index f1b39444..4453bb0b 100644 --- a/packages/vue-i18n-loader/test/custom-block.test.ts +++ b/packages/vue-i18n-loader/test/custom-block.test.ts @@ -118,29 +118,6 @@ test('global and local', async () => { expect(g.resource.en.hello(createMessageContext())).toEqual('hello global!') }) -test('bridge', async () => { - const { module } = await bundleAndRun( - 'compile.vue', - bundle, - { bridge: true }, - { - Plugin: VueLoaderPlugin, - loader: path.resolve( - __dirname, - '../../../node_modules/vue-loader15/lib/index.js' - ) - } - ) - expect(module.__i18n).toMatchSnapshot() - expect(module.__i18nBridge).toMatchSnapshot() - const l = module.__i18n.pop() - expect(l.locale).toEqual('') - expect(l.resource.en.hello(createMessageContext())).toEqual('hello world!') - const g = module.__i18nBridge.pop() - const bridgeResource = JSON.parse(g) - expect(bridgeResource.en.hello).toEqual('hello world!') -}) - test('array', async () => { const { module } = await bundleAndRun('array.vue') expect(module.__i18n).toMatchSnapshot() diff --git a/packages/vue-i18n-loader/test/fixtures/compile.vue b/packages/vue-i18n-loader/test/fixtures/compile.vue deleted file mode 100644 index e02bf334..00000000 --- a/packages/vue-i18n-loader/test/fixtures/compile.vue +++ /dev/null @@ -1,26 +0,0 @@ - -{ - "en": { - "hello": "hello world!", - "named": "hi, {name} !", - "list": "hi, {0} !", - "literal": "hi, { 'kazupon' } !", - "linked": "hi, @:name !", - "plural": "@.caml:{'no apples'} | {0} apple | {n} apples", - "nest": { - "lieteral": "hi, kazupon !" - }, - "hi, {name} !": "hi hi!", - "こんにちは": "こんにちは!", - "single-quote": "I don't know!", - "emoji": "😺", - "unicode": "\u0041", - "unicode-escape": "\\u0041", - "backslash-single-quote": "\\'", - "backslash-backslash": "\\\\" - }, - "ja": { - "hello": "こんにちは!" - } -} - From 6ba93afd17d33272883a760f9f5effcecee3a572 Mon Sep 17 00:00:00 2001 From: babu-ch Date: Thu, 20 Feb 2025 15:59:51 +0900 Subject: [PATCH 5/9] support v12: remove bridge --- packages/vue-i18n-loader/README.md | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/packages/vue-i18n-loader/README.md b/packages/vue-i18n-loader/README.md index 338f1119..f0a08947 100644 --- a/packages/vue-i18n-loader/README.md +++ b/packages/vue-i18n-loader/README.md @@ -302,14 +302,6 @@ module.exports = { } ``` -## i18n custom block bridge mode - -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. - -This is for use when using vue-i18n@v8.x + [vue-i18n-bridge](https://github.com/intlify/vue-i18n-next/tree/master/packages/vue-i18n-bridge). - -About details, See here. - ## 🔧 Options ### `forceStringify` @@ -402,17 +394,6 @@ About details, See here. Whether to generate source map. -### `bridge` - -- **Type:** `boolean` -- **Default:** `false` - - 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. - - > ⚠️ Note that if you set `bridge: true`, the bundle size will increase. It is recommended to disable this mode after the migration from vue-i18n@v8.26 to vue-i18n@v9.x is completed. - ### `useClassComponent` - **Type:** `boolean` From df0d1184327eba3987e2c416b7581ff766840c4c Mon Sep 17 00:00:00 2001 From: babu-ch Date: Fri, 21 Feb 2025 11:48:01 +0900 Subject: [PATCH 6/9] support v12: revert rollup-plugin, vite-plugin and loader --- .../e2e/example.test.js | 25 ++++++++++++ .../examples/composition/main.js | 1 + .../examples/global/main.js | 1 + .../examples/legacy/App.vue | 35 +++++++++++++++++ .../examples/legacy/Banana.vue | 19 ++++++++++ .../examples/legacy/index.html | 13 +++++++ .../examples/legacy/locales/en.yaml | 3 ++ .../examples/legacy/locales/ja.json | 6 +++ .../examples/legacy/main.js | 20 ++++++++++ packages/rollup-plugin-vue-i18n/package.json | 2 + packages/vite-plugin-vue-i18n/README.md | 20 ++++++++-- .../vite-plugin-vue-i18n/e2e/legacy.test.js | 26 +++++++++++++ .../examples/composition/main.ts | 1 + .../examples/composition/vite.config.ts | 3 +- .../examples/global/main.ts | 1 + .../examples/global/vite.config.ts | 7 +++- .../examples/legacy/App.vue | 35 +++++++++++++++++ .../examples/legacy/Banana.vue | 19 ++++++++++ .../examples/legacy/index.html | 11 ++++++ .../examples/legacy/locales/en.yaml | 3 ++ .../examples/legacy/locales/ja.json | 6 +++ .../examples/legacy/main.ts | 19 ++++++++++ .../examples/legacy/vite.config.ts | 14 +++++++ .../examples/vite.config.ts | 6 ++- packages/vite-plugin-vue-i18n/package.json | 1 + packages/vite-plugin-vue-i18n/src/check.ts | 11 ++++++ packages/vite-plugin-vue-i18n/src/index.ts | 29 +++++++++++--- packages/vite-plugin-vue-i18n/src/options.ts | 1 + packages/vue-i18n-loader/README.md | 19 ++++++++++ packages/vue-i18n-loader/e2e/legacy.test.js | 26 +++++++++++++ .../examples/composition/main.js | 1 + .../vue-i18n-loader/examples/global/main.js | 1 + .../vue-i18n-loader/examples/legacy/App.vue | 35 +++++++++++++++++ .../examples/legacy/Banana.vue | 19 ++++++++++ .../examples/legacy/index.html | 13 +++++++ .../examples/legacy/locales/en.yaml | 3 ++ .../examples/legacy/locales/ja.json | 6 +++ .../vue-i18n-loader/examples/legacy/main.js | 20 ++++++++++ .../examples/webpack.config.js | 6 ++- packages/vue-i18n-loader/src/index.ts | 12 +++++- packages/vue-i18n-loader/src/legacy.ts | 38 +++++++++++++++++++ packages/vue-i18n-loader/src/options.ts | 1 + .../__snapshots__/custom-block.test.ts.snap | 38 +++++++++++++++++++ .../vue-i18n-loader/test/custom-block.test.ts | 23 +++++++++++ .../vue-i18n-loader/test/fixtures/compile.vue | 26 +++++++++++++ 45 files changed, 609 insertions(+), 16 deletions(-) create mode 100644 packages/rollup-plugin-vue-i18n/examples/legacy/App.vue create mode 100644 packages/rollup-plugin-vue-i18n/examples/legacy/Banana.vue create mode 100644 packages/rollup-plugin-vue-i18n/examples/legacy/index.html create mode 100644 packages/rollup-plugin-vue-i18n/examples/legacy/locales/en.yaml create mode 100644 packages/rollup-plugin-vue-i18n/examples/legacy/locales/ja.json create mode 100644 packages/rollup-plugin-vue-i18n/examples/legacy/main.js create mode 100644 packages/vite-plugin-vue-i18n/e2e/legacy.test.js create mode 100644 packages/vite-plugin-vue-i18n/examples/legacy/App.vue create mode 100644 packages/vite-plugin-vue-i18n/examples/legacy/Banana.vue create mode 100644 packages/vite-plugin-vue-i18n/examples/legacy/index.html create mode 100644 packages/vite-plugin-vue-i18n/examples/legacy/locales/en.yaml create mode 100644 packages/vite-plugin-vue-i18n/examples/legacy/locales/ja.json create mode 100644 packages/vite-plugin-vue-i18n/examples/legacy/main.ts create mode 100644 packages/vite-plugin-vue-i18n/examples/legacy/vite.config.ts create mode 100644 packages/vite-plugin-vue-i18n/src/check.ts create mode 100644 packages/vue-i18n-loader/e2e/legacy.test.js create mode 100644 packages/vue-i18n-loader/examples/legacy/App.vue create mode 100644 packages/vue-i18n-loader/examples/legacy/Banana.vue create mode 100644 packages/vue-i18n-loader/examples/legacy/index.html create mode 100644 packages/vue-i18n-loader/examples/legacy/locales/en.yaml create mode 100644 packages/vue-i18n-loader/examples/legacy/locales/ja.json create mode 100644 packages/vue-i18n-loader/examples/legacy/main.js create mode 100644 packages/vue-i18n-loader/src/legacy.ts create mode 100644 packages/vue-i18n-loader/test/fixtures/compile.vue diff --git a/packages/rollup-plugin-vue-i18n/e2e/example.test.js b/packages/rollup-plugin-vue-i18n/e2e/example.test.js index cc8c6e8e..ab79ec86 100644 --- a/packages/rollup-plugin-vue-i18n/e2e/example.test.js +++ b/packages/rollup-plugin-vue-i18n/e2e/example.test.js @@ -21,6 +21,31 @@ describe('composition', () => { }) }) +describe('legacy', () => { + beforeAll(async () => { + await page.goto(`http://localhost:8080/legacy/`) + }) + + test('initial rendering', async () => { + await expect(page).toMatch('言語') + await expect(page).toMatch('こんにちは、世界!') + await expect(page).toMatch('バナナが欲しい?') + }) + + test('change select', async () => { + await page.select('#fruits select', '2') + await expect(page).toMatch('バナナ 2 個') + }) + + test('change locale', async () => { + await page.select('#app select', 'en') + await expect(page).toMatch('Language') + await expect(page).toMatch('hello, world!') + await expect(page).toMatch('Do you want banana?') + await expect(page).toMatch('2 bananas') + }) +}) + describe('global', () => { beforeAll(async () => { await page.goto(`http://localhost:8080/global/`) diff --git a/packages/rollup-plugin-vue-i18n/examples/composition/main.js b/packages/rollup-plugin-vue-i18n/examples/composition/main.js index e28b6f3a..f33acd09 100644 --- a/packages/rollup-plugin-vue-i18n/examples/composition/main.js +++ b/packages/rollup-plugin-vue-i18n/examples/composition/main.js @@ -6,6 +6,7 @@ import ja from './locales/ja.json5' import en from './locales/en.yaml' const i18n = createI18n({ + legacy: false, locale: 'ja', messages: { en, diff --git a/packages/rollup-plugin-vue-i18n/examples/global/main.js b/packages/rollup-plugin-vue-i18n/examples/global/main.js index c6ecba45..35db3fb8 100644 --- a/packages/rollup-plugin-vue-i18n/examples/global/main.js +++ b/packages/rollup-plugin-vue-i18n/examples/global/main.js @@ -3,6 +3,7 @@ import { createI18n } from 'vue-i18n' import App from './App.vue' const i18n = createI18n({ + legacy: false, locale: 'ja', messages: {} }) diff --git a/packages/rollup-plugin-vue-i18n/examples/legacy/App.vue b/packages/rollup-plugin-vue-i18n/examples/legacy/App.vue new file mode 100644 index 00000000..6f523ad1 --- /dev/null +++ b/packages/rollup-plugin-vue-i18n/examples/legacy/App.vue @@ -0,0 +1,35 @@ + + + + + +{ + "en": { + "language": "Language", + "hello": "hello, world!" + }, + "ja": { + "language": "言語", + "hello": "こんにちは、世界!" + } +} + diff --git a/packages/rollup-plugin-vue-i18n/examples/legacy/Banana.vue b/packages/rollup-plugin-vue-i18n/examples/legacy/Banana.vue new file mode 100644 index 00000000..289946aa --- /dev/null +++ b/packages/rollup-plugin-vue-i18n/examples/legacy/Banana.vue @@ -0,0 +1,19 @@ + + + diff --git a/packages/rollup-plugin-vue-i18n/examples/legacy/index.html b/packages/rollup-plugin-vue-i18n/examples/legacy/index.html new file mode 100644 index 00000000..7ce255f0 --- /dev/null +++ b/packages/rollup-plugin-vue-i18n/examples/legacy/index.html @@ -0,0 +1,13 @@ + + + + + rollup-plugin-vue-i18n composable example + + +
+ +
+ + + diff --git a/packages/rollup-plugin-vue-i18n/examples/legacy/locales/en.yaml b/packages/rollup-plugin-vue-i18n/examples/legacy/locales/en.yaml new file mode 100644 index 00000000..85d055d8 --- /dev/null +++ b/packages/rollup-plugin-vue-i18n/examples/legacy/locales/en.yaml @@ -0,0 +1,3 @@ +select: Do you want banana? +fruits: + banana: 'no bananas | {n} banana | {n} bananas' diff --git a/packages/rollup-plugin-vue-i18n/examples/legacy/locales/ja.json b/packages/rollup-plugin-vue-i18n/examples/legacy/locales/ja.json new file mode 100644 index 00000000..df96dc6f --- /dev/null +++ b/packages/rollup-plugin-vue-i18n/examples/legacy/locales/ja.json @@ -0,0 +1,6 @@ +{ + "select": "バナナが欲しい?", + "fruits": { + "banana": "バナナがない | バナナ {n} 個" + } +} diff --git a/packages/rollup-plugin-vue-i18n/examples/legacy/main.js b/packages/rollup-plugin-vue-i18n/examples/legacy/main.js new file mode 100644 index 00000000..9a92e175 --- /dev/null +++ b/packages/rollup-plugin-vue-i18n/examples/legacy/main.js @@ -0,0 +1,20 @@ +import { createApp } from 'vue' +import { createI18n } from 'vue-i18n' +import App from './App.vue' + +import ja from './locales/ja.json' +import en from './locales/en.yaml' + +const i18n = createI18n({ + legacy: true, + locale: 'ja', + messages: { + en, + ja + } +}) + +const app = createApp(App) + +app.use(i18n) +app.mount('#app') diff --git a/packages/rollup-plugin-vue-i18n/package.json b/packages/rollup-plugin-vue-i18n/package.json index e995e851..558e0ab6 100644 --- a/packages/rollup-plugin-vue-i18n/package.json +++ b/packages/rollup-plugin-vue-i18n/package.json @@ -62,10 +62,12 @@ "build:example": "yarn build && npm-run-all --parallel \"build:example:*\"", "build:example:composition": "rollup -c ./examples/rollup.config.js --environment BUILD:composition", "build:example:global": "rollup -c ./examples/rollup.config.js --environment BUILD:global", + "build:example:legacy": "rollup -c ./examples/rollup.config.js --environment BUILD:legacy", "clean": "npm-run-all \"clean:*\"", "clean:example": "npm-run-all \"clean:example:*\"", "clean:example:composition": "rm -rf ./examples/composition/index.js", "clean:example:global": "rm -rf ./examples/global/index.js", + "clean:example:legacy": "rm -rf ./examples/legacy/index.js", "clean:lib": "rm -rf ./lib", "test": "yarn test:e2e", "test:e2e": "yarn build:example && jest --runInBand --config ./jest.e2e.config.js", diff --git a/packages/vite-plugin-vue-i18n/README.md b/packages/vite-plugin-vue-i18n/README.md index c0061d36..c38d40c9 100644 --- a/packages/vite-plugin-vue-i18n/README.md +++ b/packages/vite-plugin-vue-i18n/README.md @@ -37,7 +37,9 @@ $ yarn add -D @intlify/vite-plugin-vue-i18n ## ⚠️ Notice -If you do a production build with vite, Vue I18n will automatically bundle the runtime only module. If you need on-demand compilation with Message compiler, you need to set the `runtimeOnly` option to `false`. +When this plugin is installed, Vue I18n can only use the Composition API, and if you want to use the Legacy API, you need to set the `compositionOnly` option to `false`. + +Also, if you do a production build with vite, Vue I18n will automatically bundle the runtime only module. If you need on-demand compilation with Message compiler, you need to set the `runtimeOnly` option to `false`. ## 🚀 Usage @@ -62,6 +64,9 @@ export default defineConfig({ plugins: [ vue(), // you need to install `@vitejs/plugin-vue` vueI18n({ + // if you want to use Vue I18n Legacy API, you need to set `compositionOnly: false` + // compositionOnly: false, + // you need to set i18n resource including paths ! include: resolve( dirname(fileURLToPath(import.meta.url)), @@ -265,6 +270,15 @@ About details, See the below section For more details, See [here](#-automatic-bundling) +### `compositionOnly` + +- **Type:** `boolean` +- **Default:** `true` + + Whether to make vue-i18n's API only composition API. **By default the legacy API is tree-shaken.** + + For more details, See [here](https://vue-i18n.intlify.dev/guide/advanced/optimization.html#reduce-bundle-size-with-feature-build-flags) + ### `fullInstall` - **Type:** `boolean` @@ -272,7 +286,7 @@ About details, See the below section 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, **build-in components and directive will not be installed in vue and will be tree-shaken.** + If `false` is specified, **buld-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) @@ -399,7 +413,7 @@ About details, See the below section 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 enhancement. + This option allows a smooth migration from `petite-vue-i18n` to `vue-i18n` and allows progressive enhacement. ## 📜 Changelog diff --git a/packages/vite-plugin-vue-i18n/e2e/legacy.test.js b/packages/vite-plugin-vue-i18n/e2e/legacy.test.js new file mode 100644 index 00000000..8cfe1f8e --- /dev/null +++ b/packages/vite-plugin-vue-i18n/e2e/legacy.test.js @@ -0,0 +1,26 @@ +describe('legacy', () => { + beforeAll(async () => { + await page.goto(`http://localhost:8080/legacy/`) + }) + + test('initial rendering', async () => { + await expect(page).toMatch('言語') + await expect(page).toMatch('こんにちは、世界!') + await expect(page).toMatch('バナナが欲しい?') + await expect(page).toMatch('バナナ 0 個') + }) + + test('change locale', async () => { + await page.select('#app select', 'en') + await expect(page).toMatch('Language') + await expect(page).toMatch('hello, world!') + await expect(page).toMatch('no bananas') + }) + + test('change banana select', async () => { + await page.select('#fruits select', '3') + await expect(page).toMatch('3 bananas') + await page.select('#app select', 'ja') + await expect(page).toMatch('バナナ 3 個') + }) +}) diff --git a/packages/vite-plugin-vue-i18n/examples/composition/main.ts b/packages/vite-plugin-vue-i18n/examples/composition/main.ts index 1c1397ff..94e1ec70 100644 --- a/packages/vite-plugin-vue-i18n/examples/composition/main.ts +++ b/packages/vite-plugin-vue-i18n/examples/composition/main.ts @@ -4,6 +4,7 @@ import App from './App.vue' import messages from '@intlify/vite-plugin-vue-i18n/messages' const i18n = createI18n({ + legacy: false, locale: 'ja', messages }) diff --git a/packages/vite-plugin-vue-i18n/examples/composition/vite.config.ts b/packages/vite-plugin-vue-i18n/examples/composition/vite.config.ts index acc30e30..fae599ad 100644 --- a/packages/vite-plugin-vue-i18n/examples/composition/vite.config.ts +++ b/packages/vite-plugin-vue-i18n/examples/composition/vite.config.ts @@ -7,7 +7,8 @@ export default defineConfig({ plugins: [ vue(), vueI18n({ - include: path.resolve(__dirname, './locales/**') + include: path.resolve(__dirname, './locales/**'), + compositionOnly: true }) ] }) diff --git a/packages/vite-plugin-vue-i18n/examples/global/main.ts b/packages/vite-plugin-vue-i18n/examples/global/main.ts index fa935eab..1981ee31 100644 --- a/packages/vite-plugin-vue-i18n/examples/global/main.ts +++ b/packages/vite-plugin-vue-i18n/examples/global/main.ts @@ -3,6 +3,7 @@ import { createI18n } from 'vue-i18n' import App from './App.vue' const i18n = createI18n({ + legacy: false, locale: 'ja' }) diff --git a/packages/vite-plugin-vue-i18n/examples/global/vite.config.ts b/packages/vite-plugin-vue-i18n/examples/global/vite.config.ts index 817c8827..19cc7848 100644 --- a/packages/vite-plugin-vue-i18n/examples/global/vite.config.ts +++ b/packages/vite-plugin-vue-i18n/examples/global/vite.config.ts @@ -3,5 +3,10 @@ import vue from '@vitejs/plugin-vue' import vueI18n from '../../src/index' export default defineConfig({ - plugins: [vue(), vueI18n({})] + plugins: [ + vue(), + vueI18n({ + compositionOnly: true + }) + ] }) diff --git a/packages/vite-plugin-vue-i18n/examples/legacy/App.vue b/packages/vite-plugin-vue-i18n/examples/legacy/App.vue new file mode 100644 index 00000000..6f523ad1 --- /dev/null +++ b/packages/vite-plugin-vue-i18n/examples/legacy/App.vue @@ -0,0 +1,35 @@ + + + + + +{ + "en": { + "language": "Language", + "hello": "hello, world!" + }, + "ja": { + "language": "言語", + "hello": "こんにちは、世界!" + } +} + diff --git a/packages/vite-plugin-vue-i18n/examples/legacy/Banana.vue b/packages/vite-plugin-vue-i18n/examples/legacy/Banana.vue new file mode 100644 index 00000000..289946aa --- /dev/null +++ b/packages/vite-plugin-vue-i18n/examples/legacy/Banana.vue @@ -0,0 +1,19 @@ + + + diff --git a/packages/vite-plugin-vue-i18n/examples/legacy/index.html b/packages/vite-plugin-vue-i18n/examples/legacy/index.html new file mode 100644 index 00000000..efaeb43f --- /dev/null +++ b/packages/vite-plugin-vue-i18n/examples/legacy/index.html @@ -0,0 +1,11 @@ + + + + + vite-plugin-vue-i18n legacy example + + +
+ + + diff --git a/packages/vite-plugin-vue-i18n/examples/legacy/locales/en.yaml b/packages/vite-plugin-vue-i18n/examples/legacy/locales/en.yaml new file mode 100644 index 00000000..85d055d8 --- /dev/null +++ b/packages/vite-plugin-vue-i18n/examples/legacy/locales/en.yaml @@ -0,0 +1,3 @@ +select: Do you want banana? +fruits: + banana: 'no bananas | {n} banana | {n} bananas' diff --git a/packages/vite-plugin-vue-i18n/examples/legacy/locales/ja.json b/packages/vite-plugin-vue-i18n/examples/legacy/locales/ja.json new file mode 100644 index 00000000..df96dc6f --- /dev/null +++ b/packages/vite-plugin-vue-i18n/examples/legacy/locales/ja.json @@ -0,0 +1,6 @@ +{ + "select": "バナナが欲しい?", + "fruits": { + "banana": "バナナがない | バナナ {n} 個" + } +} diff --git a/packages/vite-plugin-vue-i18n/examples/legacy/main.ts b/packages/vite-plugin-vue-i18n/examples/legacy/main.ts new file mode 100644 index 00000000..0f96f596 --- /dev/null +++ b/packages/vite-plugin-vue-i18n/examples/legacy/main.ts @@ -0,0 +1,19 @@ +import { createApp } from 'vue' +import { createI18n } from 'vue-i18n' +import App from './App.vue' +import en from './locales/en.yaml' +import ja from './locales/ja.json' + +const i18n = createI18n({ + legacy: true, + locale: 'ja', + messages: { + en, + ja + } +}) + +const app = createApp(App) + +app.use(i18n) +app.mount('#app') diff --git a/packages/vite-plugin-vue-i18n/examples/legacy/vite.config.ts b/packages/vite-plugin-vue-i18n/examples/legacy/vite.config.ts new file mode 100644 index 00000000..7166e2b2 --- /dev/null +++ b/packages/vite-plugin-vue-i18n/examples/legacy/vite.config.ts @@ -0,0 +1,14 @@ +import path from 'path' +import { defineConfig } from 'vite' +import vue from '@vitejs/plugin-vue' +import vueI18n from '../../src/index' + +export default defineConfig({ + plugins: [ + vue(), + vueI18n({ + include: path.resolve(__dirname, './locales/**'), + compositionOnly: false + }) + ] +}) diff --git a/packages/vite-plugin-vue-i18n/examples/vite.config.ts b/packages/vite-plugin-vue-i18n/examples/vite.config.ts index 9fb54527..d77515ed 100644 --- a/packages/vite-plugin-vue-i18n/examples/vite.config.ts +++ b/packages/vite-plugin-vue-i18n/examples/vite.config.ts @@ -16,14 +16,16 @@ export default defineConfig({ rollupOptions: { input: { composition: path.resolve(__dirname, './composition/index.html'), - global: path.resolve(__dirname, './global/index.html') + global: path.resolve(__dirname, './global/index.html'), + legacy: path.resolve(__dirname, './legacy/index.html') } } }, plugins: [ vue(), vueI18n({ - include: path.resolve(__dirname, './**/locales/**') + include: path.resolve(__dirname, './**/locales/**'), + compositionOnly: false }) ] }) diff --git a/packages/vite-plugin-vue-i18n/package.json b/packages/vite-plugin-vue-i18n/package.json index 0cfc39bd..bcd45cd8 100644 --- a/packages/vite-plugin-vue-i18n/package.json +++ b/packages/vite-plugin-vue-i18n/package.json @@ -84,6 +84,7 @@ "dev": "vite examples --config ./examples/vite.config.ts", "dev:composition": "vite examples/composition --config ./examples/composition/vite.config.ts", "dev:global": "vite examples/global --config ./examples/global/vite.config.ts", + "dev:legacy": "vite examples/legacy --config ./examples/legacy/vite.config.ts", "test": "yarn test:e2e", "test:e2e": "jest --runInBand --config ./jest.e2e.config.js", "watch": "tsc -p . --watch", diff --git a/packages/vite-plugin-vue-i18n/src/check.ts b/packages/vite-plugin-vue-i18n/src/check.ts new file mode 100644 index 00000000..cfddb711 --- /dev/null +++ b/packages/vite-plugin-vue-i18n/src/check.ts @@ -0,0 +1,11 @@ +// eslint-disable-next-line @typescript-eslint/ban-types +export function checkVueI18nBridgeInstallPackage(debug: Function): boolean { + let ret = false + try { + debug(`vue-i18n-bridge load path: ${require.resolve('vue-i18n-bridge')}`) + ret = true + } catch (e) { + debug(`cannot find 'vue-i18n-bridge'`, e) + } + return ret +} diff --git a/packages/vite-plugin-vue-i18n/src/index.ts b/packages/vite-plugin-vue-i18n/src/index.ts index a093e958..ddc19322 100644 --- a/packages/vite-plugin-vue-i18n/src/index.ts +++ b/packages/vite-plugin-vue-i18n/src/index.ts @@ -18,6 +18,7 @@ import createDebug from 'debug' import { normalizePath } from 'vite' import { RawSourceMap } from 'source-map' import { parseVueRequest } from './query' +import { checkVueI18nBridgeInstallPackage } from './check' import type { Plugin, ResolvedConfig, UserConfig } from 'vite' import type { CodeGenOptions, DevEnv } from '@intlify/bundle-utils' @@ -30,6 +31,7 @@ const INTLIFY_FEATURE_FLAGS_ID = '@intlify-feature-flags' const INTLIFY_FEATURE_PROXY_SUFFIX = 'inject-feature-proxy' const installedPkg = checkInstallPackage('@intlify/vite-plugin-vue-i18n', debug) +const installedVueI18nBridge = checkVueI18nBridgeInstallPackage(debug) const VIRTUAL_PREFIX = '\0' @@ -61,6 +63,12 @@ function pluginI18n( ? options.runtimeOnly : true // prettier-ignore + const compositionOnly = installedPkg === 'vue-i18n' + ? isBoolean(options.compositionOnly) + ? options.compositionOnly + : true + : true + // prettier-ignore const fullInstall = installedPkg === 'vue-i18n' ? isBoolean(options.fullInstall) ? options.fullInstall @@ -78,11 +86,15 @@ function pluginI18n( } // prettier-ignore const getAliasName = () => - installedPkg === 'petite-vue-i18n' && isBoolean(useVueI18nImportName) && + installedVueI18nBridge && installedPkg === 'vue-i18n' + ? 'vue-i18n-bridge' + : installedPkg === 'petite-vue-i18n' && isBoolean(useVueI18nImportName) && useVueI18nImportName ? 'vue-i18n' : `${installedPkg}` - const runtimeModule = `${installedPkg}.runtime.js` + const runtimeModule = `${ + installedVueI18nBridge ? 'vue-i18n-bridge' : installedPkg + }.runtime.mjs` const forceStringify = !!options.forceStringify let isProduction = false @@ -124,17 +136,21 @@ function pluginI18n( if (isArray(config.resolve!.alias)) { config.resolve!.alias.push({ find: 'vue-i18n', - replacement: `petite-vue-i18n/dist/petite-vue-i18n.js` + replacement: `petite-vue-i18n/dist/petite-vue-i18n.mjs` }) } else { // eslint-disable-next-line @typescript-eslint/no-explicit-any ;(config.resolve!.alias as any)['vue-i18n'] = - `petite-vue-i18n/dist/petite-vue-i18n.js` + `petite-vue-i18n/dist/petite-vue-i18n.mjs` } debug(`alias name: ${getAliasName()}`) } config.define = config.define || {} + config.define['__VUE_I18N_LEGACY_API__'] = !compositionOnly + debug( + `set __VUE_I18N_LEGACY_API__ is '${config.define['__VUE_I18N_LEGACY_API__']}'` + ) config.define['__VUE_I18N_FULL_INSTALL__'] = fullInstall debug( @@ -213,12 +229,13 @@ function pluginI18n( * NOTE: * Vue SSR with Vite3 (esm) will be worked on `@vue/server-renderer` with cjs. * This prevents the vue feature flag (`__VUE_PROD_DEVTOOLS__`) - * and the vue-i18n feature flags used in `(petite)-vue-i18n.runtime.js` from being set. - * To work around this problem, proxy using the virtual module of vite (rollup) + * and the vue-i18n feature flags used in `(petitle)-vue-i18n.runtime.mjs` from being set. + * To work around this problem, proxy using the virutal module of vite (rollup) */ if (options?.ssr) { if (getVirtualId(id) === INTLIFY_FEATURE_FLAGS_ID) { return `import { getGlobalThis } from '@intlify/shared'; +getGlobalThis().__VUE_I18N_LEGACY_API__ = ${JSON.stringify(!compositionOnly)}; getGlobalThis().__VUE_I18N_FULL_INSTALL__ = ${JSON.stringify(fullInstall)}; getGlobalThis().__VUE_I18N_PROD_DEVTOOLS__ = false; getGlobalThis().__VUE_PROD_DEVTOOLS__ = false; diff --git a/packages/vite-plugin-vue-i18n/src/options.ts b/packages/vite-plugin-vue-i18n/src/options.ts index ca39d7b6..86886eb6 100644 --- a/packages/vite-plugin-vue-i18n/src/options.ts +++ b/packages/vite-plugin-vue-i18n/src/options.ts @@ -1,6 +1,7 @@ export type VitePluginVueI18nOptions = { forceStringify?: boolean runtimeOnly?: boolean + compositionOnly?: boolean fullInstall?: boolean include?: string | string[] defaultSFCLang?: 'json' | 'json5' | 'yml' | 'yaml' diff --git a/packages/vue-i18n-loader/README.md b/packages/vue-i18n-loader/README.md index f0a08947..338f1119 100644 --- a/packages/vue-i18n-loader/README.md +++ b/packages/vue-i18n-loader/README.md @@ -302,6 +302,14 @@ module.exports = { } ``` +## i18n custom block bridge mode + +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. + +This is for use when using vue-i18n@v8.x + [vue-i18n-bridge](https://github.com/intlify/vue-i18n-next/tree/master/packages/vue-i18n-bridge). + +About details, See here. + ## 🔧 Options ### `forceStringify` @@ -394,6 +402,17 @@ module.exports = { Whether to generate source map. +### `bridge` + +- **Type:** `boolean` +- **Default:** `false` + + 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. + + > ⚠️ Note that if you set `bridge: true`, the bundle size will increase. It is recommended to disable this mode after the migration from vue-i18n@v8.26 to vue-i18n@v9.x is completed. + ### `useClassComponent` - **Type:** `boolean` diff --git a/packages/vue-i18n-loader/e2e/legacy.test.js b/packages/vue-i18n-loader/e2e/legacy.test.js new file mode 100644 index 00000000..8cfe1f8e --- /dev/null +++ b/packages/vue-i18n-loader/e2e/legacy.test.js @@ -0,0 +1,26 @@ +describe('legacy', () => { + beforeAll(async () => { + await page.goto(`http://localhost:8080/legacy/`) + }) + + test('initial rendering', async () => { + await expect(page).toMatch('言語') + await expect(page).toMatch('こんにちは、世界!') + await expect(page).toMatch('バナナが欲しい?') + await expect(page).toMatch('バナナ 0 個') + }) + + test('change locale', async () => { + await page.select('#app select', 'en') + await expect(page).toMatch('Language') + await expect(page).toMatch('hello, world!') + await expect(page).toMatch('no bananas') + }) + + test('change banana select', async () => { + await page.select('#fruits select', '3') + await expect(page).toMatch('3 bananas') + await page.select('#app select', 'ja') + await expect(page).toMatch('バナナ 3 個') + }) +}) diff --git a/packages/vue-i18n-loader/examples/composition/main.js b/packages/vue-i18n-loader/examples/composition/main.js index 621e22bc..f7028a77 100644 --- a/packages/vue-i18n-loader/examples/composition/main.js +++ b/packages/vue-i18n-loader/examples/composition/main.js @@ -6,6 +6,7 @@ import ja from './locales/ja.json' import en from './locales/en.yaml' const i18n = createI18n({ + legacy: false, locale: 'ja', messages: { en, diff --git a/packages/vue-i18n-loader/examples/global/main.js b/packages/vue-i18n-loader/examples/global/main.js index fce949a5..da0524ca 100644 --- a/packages/vue-i18n-loader/examples/global/main.js +++ b/packages/vue-i18n-loader/examples/global/main.js @@ -3,6 +3,7 @@ import { createI18n } from 'vue-i18n' import App from './App.vue' const i18n = createI18n({ + legacy: false, locale: 'ja', messages: { en: { diff --git a/packages/vue-i18n-loader/examples/legacy/App.vue b/packages/vue-i18n-loader/examples/legacy/App.vue new file mode 100644 index 00000000..6f523ad1 --- /dev/null +++ b/packages/vue-i18n-loader/examples/legacy/App.vue @@ -0,0 +1,35 @@ + + + + + +{ + "en": { + "language": "Language", + "hello": "hello, world!" + }, + "ja": { + "language": "言語", + "hello": "こんにちは、世界!" + } +} + diff --git a/packages/vue-i18n-loader/examples/legacy/Banana.vue b/packages/vue-i18n-loader/examples/legacy/Banana.vue new file mode 100644 index 00000000..289946aa --- /dev/null +++ b/packages/vue-i18n-loader/examples/legacy/Banana.vue @@ -0,0 +1,19 @@ + + + diff --git a/packages/vue-i18n-loader/examples/legacy/index.html b/packages/vue-i18n-loader/examples/legacy/index.html new file mode 100644 index 00000000..1e74d441 --- /dev/null +++ b/packages/vue-i18n-loader/examples/legacy/index.html @@ -0,0 +1,13 @@ + + + + + vue-i18n-loader example + + +
+ +
+ + + diff --git a/packages/vue-i18n-loader/examples/legacy/locales/en.yaml b/packages/vue-i18n-loader/examples/legacy/locales/en.yaml new file mode 100644 index 00000000..85d055d8 --- /dev/null +++ b/packages/vue-i18n-loader/examples/legacy/locales/en.yaml @@ -0,0 +1,3 @@ +select: Do you want banana? +fruits: + banana: 'no bananas | {n} banana | {n} bananas' diff --git a/packages/vue-i18n-loader/examples/legacy/locales/ja.json b/packages/vue-i18n-loader/examples/legacy/locales/ja.json new file mode 100644 index 00000000..df96dc6f --- /dev/null +++ b/packages/vue-i18n-loader/examples/legacy/locales/ja.json @@ -0,0 +1,6 @@ +{ + "select": "バナナが欲しい?", + "fruits": { + "banana": "バナナがない | バナナ {n} 個" + } +} diff --git a/packages/vue-i18n-loader/examples/legacy/main.js b/packages/vue-i18n-loader/examples/legacy/main.js new file mode 100644 index 00000000..9a92e175 --- /dev/null +++ b/packages/vue-i18n-loader/examples/legacy/main.js @@ -0,0 +1,20 @@ +import { createApp } from 'vue' +import { createI18n } from 'vue-i18n' +import App from './App.vue' + +import ja from './locales/ja.json' +import en from './locales/en.yaml' + +const i18n = createI18n({ + legacy: true, + locale: 'ja', + messages: { + en, + ja + } +}) + +const app = createApp(App) + +app.use(i18n) +app.mount('#app') diff --git a/packages/vue-i18n-loader/examples/webpack.config.js b/packages/vue-i18n-loader/examples/webpack.config.js index cc48864f..ee366b5e 100644 --- a/packages/vue-i18n-loader/examples/webpack.config.js +++ b/packages/vue-i18n-loader/examples/webpack.config.js @@ -6,6 +6,7 @@ module.exports = { devtool: 'source-map', entry: { composition: path.resolve(__dirname, './composition/main.js'), + legacy: path.resolve(__dirname, './legacy/main.js'), global: path.resolve(__dirname, './global/main.js') }, output: { @@ -40,7 +41,10 @@ module.exports = { test: /\.(json5?|ya?ml)$/, // target json, json5, yaml and yml files type: 'javascript/auto', // Use `Rule.include` to specify the files of locale messages to be pre-compiled - include: [path.resolve(__dirname, './composition/locales')], + include: [ + path.resolve(__dirname, './composition/locales'), + path.resolve(__dirname, './legacy/locales') + ], use: [ { loader: path.resolve(__dirname, '../lib/index.js'), diff --git a/packages/vue-i18n-loader/src/index.ts b/packages/vue-i18n-loader/src/index.ts index 4b1b80eb..55b3f48b 100644 --- a/packages/vue-i18n-loader/src/index.ts +++ b/packages/vue-i18n-loader/src/index.ts @@ -6,6 +6,7 @@ import { parse, ParsedUrlQuery } from 'querystring' import { RawSourceMap } from 'source-map' import { isEmptyObject, isString } from '@intlify/shared' import { generateJSON, generateYAML } from '@intlify/bundle-utils' +import { createBridgeCodeGenerator } from './legacy' import type { CodeGenOptions, DevEnv } from '@intlify/bundle-utils' import type { VueI18nLoaderOptions } from './options' @@ -17,6 +18,8 @@ const loader: LoaderDefinitionFunction = function ( sourceMap: RawSourceMap | undefined ): void { const loaderContext = this // eslint-disable-line @typescript-eslint/no-this-alias + const loaderOptions = loaderUtils.getOptions(loaderContext as any) || {} + const { bridge } = loaderOptions as VueI18nLoaderOptions const query = parse(loaderContext.resourceQuery) const options = getOptions(loaderContext, query, sourceMap) as CodeGenOptions @@ -40,7 +43,11 @@ const loader: LoaderDefinitionFunction = function ( // }) // } const generate = /json5?/.test(langInfo) ? generateJSON : generateYAML - const { code, map } = generate(source, options) + const { code, map } = generate( + source, + options, + bridge ? createBridgeCodeGenerator(source, query) : undefined + ) // console.log('code', code) this.callback(null, code, map as any) } catch (err: any) { @@ -56,11 +63,12 @@ function getOptions( ): Record { const loaderOptions = loaderUtils.getOptions(loaderContext) || {} const { resourcePath: filename, mode } = loaderContext - const { forceStringify, productionSourceMap, useClassComponent } = + const { forceStringify, productionSourceMap, bridge, useClassComponent } = loaderOptions as VueI18nLoaderOptions const baseOptions = { filename, + bridge, sourceMap: productionSourceMap || false, inSourceMap, forceStringify, diff --git a/packages/vue-i18n-loader/src/legacy.ts b/packages/vue-i18n-loader/src/legacy.ts new file mode 100644 index 00000000..3da31a47 --- /dev/null +++ b/packages/vue-i18n-loader/src/legacy.ts @@ -0,0 +1,38 @@ +import { ParsedUrlQuery } from 'querystring' +import JSON5 from 'json5' +import yaml from 'js-yaml' + +export function createBridgeCodeGenerator( + source: string | Buffer, + query: ParsedUrlQuery +): () => string { + return () => { + const data = convert(source, query.lang as string) + let value = JSON.parse(data) + + if (query.locale && typeof query.locale === 'string') { + value = Object.assign({}, { [query.locale]: value }) + } + + return JSON.stringify(value) + .replace(/\u2028/g, '\\u2028') + .replace(/\u2029/g, '\\u2029') + .replace(/\\/g, '\\\\') + .replace(/\u0027/g, '\\u0027') + } +} + +function convert(source: string | Buffer, lang: string): string { + const value = Buffer.isBuffer(source) ? source.toString() : source + + switch (lang) { + case 'yaml': + case 'yml': + const data = yaml.load(value) + return JSON.stringify(data, undefined, '\t') + case 'json5': + return JSON.stringify(JSON5.parse(value)) + default: + return value + } +} diff --git a/packages/vue-i18n-loader/src/options.ts b/packages/vue-i18n-loader/src/options.ts index 725924ed..d065f608 100644 --- a/packages/vue-i18n-loader/src/options.ts +++ b/packages/vue-i18n-loader/src/options.ts @@ -1,5 +1,6 @@ export type VueI18nLoaderOptions = { forceStringify?: boolean productionSourceMap?: boolean + bridge?: boolean useClassComponent?: boolean } diff --git a/packages/vue-i18n-loader/test/__snapshots__/custom-block.test.ts.snap b/packages/vue-i18n-loader/test/__snapshots__/custom-block.test.ts.snap index 7034a842..f3018a53 100644 --- a/packages/vue-i18n-loader/test/__snapshots__/custom-block.test.ts.snap +++ b/packages/vue-i18n-loader/test/__snapshots__/custom-block.test.ts.snap @@ -31,6 +31,44 @@ Array [ ] `; +exports[`bridge 1`] = ` +Array [ + Object { + "locale": "", + "resource": Object { + "en": Object { + "backslash-backslash": [Function], + "backslash-single-quote": [Function], + "emoji": [Function], + "hello": [Function], + "hi, {name} !": [Function], + "linked": [Function], + "list": [Function], + "literal": [Function], + "named": [Function], + "nest": Object { + "lieteral": [Function], + }, + "plural": [Function], + "single-quote": [Function], + "unicode": [Function], + "unicode-escape": [Function], + "こんにちは": [Function], + }, + "ja": Object { + "hello": [Function], + }, + }, + }, +] +`; + +exports[`bridge 2`] = ` +Array [ + "{\\"en\\":{\\"hello\\":\\"hello world!\\",\\"named\\":\\"hi, {name} !\\",\\"list\\":\\"hi, {0} !\\",\\"literal\\":\\"hi, { 'kazupon' } !\\",\\"linked\\":\\"hi, @:name !\\",\\"plural\\":\\"@.caml:{'no apples'} | {0} apple | {n} apples\\",\\"nest\\":{\\"lieteral\\":\\"hi, kazupon !\\"},\\"hi, {name} !\\":\\"hi hi!\\",\\"こんにちは\\":\\"こんにちは!\\",\\"single-quote\\":\\"I don't know!\\",\\"emoji\\":\\"😺\\",\\"unicode\\":\\"A\\",\\"unicode-escape\\":\\"\\\\\\\\u0041\\",\\"backslash-single-quote\\":\\"\\\\\\\\'\\",\\"backslash-backslash\\":\\"\\\\\\\\\\\\\\\\\\"},\\"ja\\":{\\"hello\\":\\"こんにちは!\\"}}", +] +`; + exports[`global 1`] = ` Array [ Object { diff --git a/packages/vue-i18n-loader/test/custom-block.test.ts b/packages/vue-i18n-loader/test/custom-block.test.ts index 4453bb0b..f1b39444 100644 --- a/packages/vue-i18n-loader/test/custom-block.test.ts +++ b/packages/vue-i18n-loader/test/custom-block.test.ts @@ -118,6 +118,29 @@ test('global and local', async () => { expect(g.resource.en.hello(createMessageContext())).toEqual('hello global!') }) +test('bridge', async () => { + const { module } = await bundleAndRun( + 'compile.vue', + bundle, + { bridge: true }, + { + Plugin: VueLoaderPlugin, + loader: path.resolve( + __dirname, + '../../../node_modules/vue-loader15/lib/index.js' + ) + } + ) + expect(module.__i18n).toMatchSnapshot() + expect(module.__i18nBridge).toMatchSnapshot() + const l = module.__i18n.pop() + expect(l.locale).toEqual('') + expect(l.resource.en.hello(createMessageContext())).toEqual('hello world!') + const g = module.__i18nBridge.pop() + const bridgeResource = JSON.parse(g) + expect(bridgeResource.en.hello).toEqual('hello world!') +}) + test('array', async () => { const { module } = await bundleAndRun('array.vue') expect(module.__i18n).toMatchSnapshot() diff --git a/packages/vue-i18n-loader/test/fixtures/compile.vue b/packages/vue-i18n-loader/test/fixtures/compile.vue new file mode 100644 index 00000000..e02bf334 --- /dev/null +++ b/packages/vue-i18n-loader/test/fixtures/compile.vue @@ -0,0 +1,26 @@ + +{ + "en": { + "hello": "hello world!", + "named": "hi, {name} !", + "list": "hi, {0} !", + "literal": "hi, { 'kazupon' } !", + "linked": "hi, @:name !", + "plural": "@.caml:{'no apples'} | {0} apple | {n} apples", + "nest": { + "lieteral": "hi, kazupon !" + }, + "hi, {name} !": "hi hi!", + "こんにちは": "こんにちは!", + "single-quote": "I don't know!", + "emoji": "😺", + "unicode": "\u0041", + "unicode-escape": "\\u0041", + "backslash-single-quote": "\\'", + "backslash-backslash": "\\\\" + }, + "ja": { + "hello": "こんにちは!" + } +} + From 647a438783f2405c129ae8aa7778a260d55e6fc8 Mon Sep 17 00:00:00 2001 From: babu-ch Date: Fri, 21 Feb 2025 17:22:15 +0900 Subject: [PATCH 7/9] support v12: add doc note --- packages/unplugin-vue-i18n/README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/unplugin-vue-i18n/README.md b/packages/unplugin-vue-i18n/README.md index 40cffdf2..3dbc8747 100644 --- a/packages/unplugin-vue-i18n/README.md +++ b/packages/unplugin-vue-i18n/README.md @@ -424,6 +424,18 @@ If do you will use this option, you need to enable `jitCompilation` option. For more details, See [here](#-automatic-bundling) +### `compositionOnly` + +- **Type:** `boolean` +- **Default:** `true` + + Whether to make vue-i18n API only composition API. **By default the legacy API is tree-shaken.** + + For more details, See [here](https://vue-i18n.intlify.dev/guide/advanced/optimization.html#reduce-bundle-size-with-feature-build-flags) + +> [!NOTE] +> This option will be removed in v7 + ### `fullInstall` - **Type:** `boolean` From 4f0142fa027cfb71c7fa5e3654800c43d202178d Mon Sep 17 00:00:00 2001 From: babu-ch Date: Sat, 22 Feb 2025 12:38:14 +0900 Subject: [PATCH 8/9] support v12: note to caution --- packages/unplugin-vue-i18n/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/unplugin-vue-i18n/README.md b/packages/unplugin-vue-i18n/README.md index 3dbc8747..f72c791c 100644 --- a/packages/unplugin-vue-i18n/README.md +++ b/packages/unplugin-vue-i18n/README.md @@ -433,7 +433,7 @@ 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) -> [!NOTE] +> [!CAUTION] > This option will be removed in v7 ### `fullInstall` From 3175056fe47d8096bd97fbf07c27e2db8952b7b3 Mon Sep 17 00:00:00 2001 From: babu-ch Date: Tue, 25 Feb 2025 19:15:49 +0900 Subject: [PATCH 9/9] revert sourcemap --- .../test/webpack/__snapshots__/sourcemap.test.ts.snap | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/unplugin-vue-i18n/test/webpack/__snapshots__/sourcemap.test.ts.snap b/packages/unplugin-vue-i18n/test/webpack/__snapshots__/sourcemap.test.ts.snap index da65e63e..b09a4297 100644 --- a/packages/unplugin-vue-i18n/test/webpack/__snapshots__/sourcemap.test.ts.snap +++ b/packages/unplugin-vue-i18n/test/webpack/__snapshots__/sourcemap.test.ts.snap @@ -1,12 +1,12 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`custom blocks: json 1`] = `";;;;;;;;;;AAAa;AACb,8CAA6C,EAAE,aAAa,EAAC;AAC7D;AACA;AACA,kBAAe;AACf;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AEVkE;AAClE;AACA;AACA,CAAuE;AACvE,WAAW,yFAAM,iBAAiB,6FAAM;;;AAGxC,CAAqO;AACrO,iCAAiC,gPAAe,oBAAoB,4EAAM;AAC1E;AACA,IAAI,KAAU,EAAE,EAcf;;;AAGD,iEAAe;;;;;;;;;;;;;;AC3Bf,6BAAe,oCAAU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ACA,kBAAkB,+CAAS;AAC3B,mBAAmB,oCAAO;AAC1B;;AAEA,iEAAe,+CAAS"`; +exports[`custom blocks: json5 1`] = `";;;;;;;;;;AAAa;AACb,8CAA6C,EAAE,aAAa,EAAC;AAC7D;AACA;AACA,kBAAe;AACf;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AEVkE;AAClE;AACA;AACA,CAAkF;AAClF,WAAW,oGAAM,iBAAiB,wGAAM;;;AAGxC,CAAgO;AAChO,iCAAiC,2OAAe,oBAAoB,4EAAM;AAC1E;AACA,IAAI,KAAU,EAAE,EAcf;;;AAGD,iEAAe;;;;;;;;;;;;;;AC3Bf,6BAAe,oCAAU;AACzB;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB,mCAAmC,SAAS,+BAA+B,QAAQ,iCAAiC,yBAAyB,SAAS,mCAAmC,SAAS,+BAA+B,QAAQ,kCAAkC,WAAW,mCAAmC,SAAS,+BAA+B,QAAQ,mCAAmC;AAC9Z;AACA;AACA,GAAG;AACH;;;;;;;;;;;;;;;;;;;;;;UEXA;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;;WCtBA;WACA;WACA;WACA;WACA,yCAAyC,wCAAwC;WACjF;WACA;WACA;;;;;WCPA;;;;;WCAA;WACA;WACA;WACA,uDAAuD,iBAAiB;WACxE;WACA,gDAAgD,aAAa;WAC7D;;;;;;;;;;;;;ACN+B;AACG;;AAElC;AACA,kBAAkB,+CAAS;AAC3B,mBAAmB,oCAAO;AAC1B;;AAEA,iEAAe,+CAAS"`; -exports[`custom blocks: yaml 1`] = `";;;;;;;;;;AAAa;AACb,8CAA6C,EAAE,aAAa,EAAC;AAC7D;AACA;AACA,kBAAe;AACf;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AEViE;AACjE;AACA;AAC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