Skip to content

Commit 5165c1d

Browse files
authored
breaking: drop deprecation code (#353)
* breaking: drop deprecation code * more drop * update snapshots * more droping
1 parent 37fe890 commit 5165c1d

File tree

7 files changed

+8
-267
lines changed

7 files changed

+8
-267
lines changed

packages/unplugin-vue-i18n/README.md

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -539,53 +539,6 @@ If do you will use this option, you need to enable `jitCompilation` option.
539539
</i18n>
540540
```
541541

542-
### `bridge`
543-
544-
- **Type:** `boolean`
545-
- **Default:** `false`
546-
547-
> [!WARNING]
548-
'bridge' option is deprecated, sinece Vue 2 was EOL on 2023. that option will be removed in 4.0.`
549-
550-
The mode to birdge the i18n custom block to work in both [email protected] and [email protected] environments.
551-
552-
To support in a smooth transition from [email protected] to [email protected], we provide a mode that bundles the i18n custom block to be available in either version.
553-
554-
> [!WARNING]
555-
Note that if you set `bridge: true`, the bundle size will increase. It is recommended to disable this mode after the migration from [email protected] to [email protected] is completed.
556-
557-
### `legacy`
558-
559-
- **Type:** `boolean`
560-
- **Default:** `false`
561-
562-
> [!WARNING]
563-
'legacy' option is deprecated, sinece Vue 2 was EOL on 2023. that option will be removed in 4.0.`
564-
565-
This option supports Vue I18n v8.x compatibility for resources in i18n custom blocks.
566-
567-
> [!NOTE]
568-
To work for Vue 2.7, the value of `vueVersion` must be set to `'v2.7'`.
569-
570-
### `vueVersion`
571-
572-
- **Type:** `string`
573-
- **Default:** `undefined`
574-
575-
> [!WARNING]
576-
'vueVersion' option is deprecated, sinece Vue 2 was EOL on 2023. that option will be removed in 4.0.`
577-
578-
The version of Vue that will be used by Vue I18n. This option is enabled when the `legacy` option is `true`.
579-
580-
Available values are `'v2.6'` and `'v2.7'`.
581-
582-
### `esm`
583-
584-
- **Type:** `boolean`
585-
- **Default:** `true`
586-
587-
For `bridge` option is `true`, whether to bundle locale resources with ESM. By default ESM, if you need to bundl with commonjs for especialy webpack, you need to set `false`
588-
589542
### `useClassComponent`
590543

591544
- **Type:** `boolean`

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

Lines changed: 8 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,10 @@ import {
1818
generateYAML,
1919
generateJavaScript,
2020
checkInstallPackage,
21-
checkVueI18nBridgeInstallPackage,
2221
getVueI18nVersion
2322
} from '@intlify/bundle-utils'
2423
import { parse } from '@vue/compiler-sfc'
2524
import { parseVueRequest, VueQuery } from './query'
26-
import { createBridgeCodeGenerator } from './legacy'
2725
import { getRaw, warn, error, raiseError } from './utils'
2826

2927
import type { RawSourceMap } from 'source-map-js'
@@ -41,7 +39,6 @@ const VIRTUAL_PREFIX = '\0'
4139
const debug = createDebug('unplugin-vue-i18n')
4240

4341
const installedPkg = checkInstallPackage('@intlify/unplugin-vue-i18n', debug)
44-
const installedVueI18nBridge = checkVueI18nBridgeInstallPackage(debug)
4542
const vueI18nVersion = getVueI18nVersion(debug)
4643

4744
if (vueI18nVersion === '8') {
@@ -85,31 +82,6 @@ export const unplugin = createUnplugin<PluginOptions>((options = {}, meta) => {
8582
const globalSFCScope = !!options.globalSFCScope
8683
const useClassComponent = !!options.useClassComponent
8784

88-
const bridge = !!options.bridge
89-
debug('bridge', bridge)
90-
if (bridge) {
91-
warn(
92-
`'bridge' option is deprecated, since Vue 2 was EOL on 2023. that option will be removed in 4.0.`
93-
)
94-
}
95-
96-
const legacy = !!options.legacy
97-
debug('legacy', legacy)
98-
if (legacy) {
99-
warn(
100-
`'legacy' option is deprecated, since Vue 2 was EOL on 2023. that option will be removed in 4.0.`
101-
)
102-
}
103-
104-
const vueVersion = isString(options.vueVersion)
105-
? options.vueVersion
106-
: undefined
107-
if (vueVersion) {
108-
warn(
109-
`'vueVersion' option is deprecated, since Vue 2 was EOL on 2023. that option will be removed in 4.0.`
110-
)
111-
}
112-
11385
const runtimeOnly = isBoolean(options.runtimeOnly)
11486
? options.runtimeOnly
11587
: true
@@ -152,29 +124,21 @@ export const unplugin = createUnplugin<PluginOptions>((options = {}, meta) => {
152124

153125
// prettier-ignore
154126
const getVueI18nAliasName = () =>
155-
vueI18nVersion === '9' || vueI18nVersion === '8'
127+
vueI18nVersion === '9'
156128
? 'vue-i18n'
157129
: vueI18nVersion === 'unknown' && installedPkg === 'petite-vue-i18n' && isBoolean(useVueI18nImportName) && useVueI18nImportName
158130
? 'vue-i18n'
159131
: installedPkg
160132

161-
const getVueI18nBridgeAliasPath = () =>
162-
`vue-i18n-bridge/dist/vue-i18n-bridge.runtime.esm-bundler.js`
163-
164133
const getVueI18nAliasPath = (
165134
aliasName: string,
166135
{ ssr = false, runtimeOnly = false }
167136
) => {
168-
return vueI18nVersion === '8'
169-
? `${aliasName}/dist/${aliasName}.esm.js` // for vue-i18n@8
170-
: `${aliasName}/dist/${installedPkg}${runtimeOnly ? '.runtime' : ''}.${
171-
!ssr ? 'esm-bundler.js' /* '.mjs' */ : 'node.mjs'
172-
}`
137+
return `${aliasName}/dist/${installedPkg}${runtimeOnly ? '.runtime' : ''}.${
138+
!ssr ? 'esm-bundler.js' /* '.mjs' */ : 'node.mjs'
139+
}`
173140
}
174141

175-
const esm = isBoolean(options.esm) ? options.esm : true
176-
debug('esm', esm)
177-
178142
const allowDynamic = !!options.allowDynamic
179143
debug('allowDynamic', allowDynamic)
180144

@@ -221,24 +185,13 @@ export const unplugin = createUnplugin<PluginOptions>((options = {}, meta) => {
221185
runtimeOnly
222186
})
223187
})
224-
if (installedVueI18nBridge) {
225-
config.resolve!.alias.push({
226-
find: 'vue-i18n-bridge',
227-
replacement: getVueI18nBridgeAliasPath()
228-
})
229-
}
230188
} else if (isObject(config.resolve!.alias)) {
231189
// eslint-disable-next-line @typescript-eslint/no-explicit-any
232190
;(config.resolve!.alias as any)[vueI18nAliasName] =
233191
getVueI18nAliasPath(vueI18nAliasName, {
234192
ssr: ssrBuild,
235193
runtimeOnly
236194
})
237-
if (installedVueI18nBridge) {
238-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
239-
;(config.resolve!.alias as any)['vue-i18n-bridge'] =
240-
getVueI18nBridgeAliasPath()
241-
}
242195
}
243196
debug(
244197
`set ${vueI18nAliasName} runtime only: ${getVueI18nAliasPath(
@@ -249,11 +202,6 @@ export const unplugin = createUnplugin<PluginOptions>((options = {}, meta) => {
249202
}
250203
)}`
251204
)
252-
if (installedVueI18nBridge) {
253-
debug(
254-
`set vue-i18n-bridge runtime only: ${getVueI18nBridgeAliasPath()}`
255-
)
256-
}
257205
} else if (
258206
command === 'serve' &&
259207
installedPkg === 'petite-vue-i18n' &&
@@ -380,22 +328,14 @@ export const unplugin = createUnplugin<PluginOptions>((options = {}, meta) => {
380328
allowDynamic,
381329
strictMessage,
382330
escapeHtml,
383-
bridge,
384-
legacy,
385-
vueVersion,
386331
jit: jitCompilation,
387332
onlyLocales,
388-
exportESM: esm,
389333
forceStringify
390334
}
391335
) as CodeGenOptions
392336
debug('parseOptions', parseOptions)
393337

394-
const { code: generatedCode, map } = generate(
395-
_code,
396-
parseOptions,
397-
bridge ? createBridgeCodeGenerator(_code, query) : undefined
398-
)
338+
const { code: generatedCode, map } = generate(_code, parseOptions)
399339
debug('generated code', generatedCode)
400340
debug('sourcemap', map, sourceMap)
401341

@@ -447,22 +387,12 @@ export const unplugin = createUnplugin<PluginOptions>((options = {}, meta) => {
447387
ssr: ssrBuild,
448388
runtimeOnly
449389
})
450-
if (installedVueI18nBridge) {
451-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
452-
;(compiler.options.resolve!.alias as any)['vue-i18n-bridge'] =
453-
getVueI18nBridgeAliasPath()
454-
}
455390
debug(
456391
`set ${vueI18nAliasName}: ${getVueI18nAliasPath(vueI18nAliasName, {
457392
ssr: ssrBuild,
458393
runtimeOnly
459394
})}`
460395
)
461-
if (installedVueI18nBridge) {
462-
debug(
463-
`set vue-i18n-bridge runtime only: ${getVueI18nBridgeAliasPath()}`
464-
)
465-
}
466396
} else if (
467397
!isProduction &&
468398
installedPkg === 'petite-vue-i18n' &&
@@ -538,10 +468,8 @@ export const unplugin = createUnplugin<PluginOptions>((options = {}, meta) => {
538468
isProduction,
539469
{
540470
forceStringify,
541-
bridge,
542471
strictMessage,
543472
escapeHtml,
544-
exportESM: esm,
545473
useClassComponent
546474
}
547475
)
@@ -593,20 +521,14 @@ export const unplugin = createUnplugin<PluginOptions>((options = {}, meta) => {
593521
allowDynamic,
594522
strictMessage,
595523
escapeHtml,
596-
bridge,
597524
jit: jitCompilation,
598525
onlyLocales,
599-
exportESM: esm,
600526
forceStringify
601527
}
602528
) as CodeGenOptions
603529
debug('parseOptions', parseOptions)
604530

605-
const { code: generatedCode, map } = generate(
606-
code,
607-
parseOptions,
608-
bridge ? createBridgeCodeGenerator(code, query) : undefined
609-
)
531+
const { code: generatedCode, map } = generate(code, parseOptions)
610532
debug('generated code', generatedCode)
611533
debug('sourcemap', map, sourceMap)
612534

@@ -654,14 +576,10 @@ export const unplugin = createUnplugin<PluginOptions>((options = {}, meta) => {
654576
inSourceMap,
655577
isGlobal: globalSFCScope,
656578
useClassComponent,
657-
bridge,
658-
legacy,
659-
vueVersion,
660579
jit: jitCompilation,
661580
strictMessage,
662581
escapeHtml,
663582
onlyLocales,
664-
exportESM: esm,
665583
forceStringify
666584
}
667585
) as CodeGenOptions
@@ -674,11 +592,7 @@ export const unplugin = createUnplugin<PluginOptions>((options = {}, meta) => {
674592
query,
675593
meta.framework
676594
)
677-
const { code: generatedCode, map } = generate(
678-
source,
679-
parseOptions,
680-
bridge ? createBridgeCodeGenerator(source, query) : undefined
681-
)
595+
const { code: generatedCode, map } = generate(source, parseOptions)
682596
debug('generated code', generatedCode)
683597
debug('sourcemap', map, sourceMap)
684598

@@ -753,19 +667,15 @@ async function generateBundleResources(
753667
{
754668
forceStringify = false,
755669
isGlobal = false,
756-
bridge = false,
757670
onlyLocales = [],
758-
exportESM = true,
759671
strictMessage = true,
760672
escapeHtml = false,
761673
useClassComponent = false,
762674
jit = false
763675
}: {
764676
forceStringify?: boolean
765677
isGlobal?: boolean
766-
bridge?: boolean
767678
onlyLocales?: string[]
768-
exportESM?: boolean
769679
strictMessage?: boolean
770680
escapeHtml?: boolean
771681
useClassComponent?: boolean
@@ -783,20 +693,14 @@ async function generateBundleResources(
783693
const parseOptions = getOptions(res, isProduction, {}, false, {
784694
isGlobal,
785695
useClassComponent,
786-
bridge,
787696
jit,
788697
onlyLocales,
789-
exportESM,
790698
strictMessage,
791699
escapeHtml,
792700
forceStringify
793701
}) as CodeGenOptions
794702
parseOptions.type = 'bare'
795-
const { code } = generate(
796-
source,
797-
parseOptions,
798-
bridge ? createBridgeCodeGenerator(source, query) : undefined
799-
)
703+
const { code } = generate(source, parseOptions)
800704

801705
debug('generated code', code)
802706
codes.push(`${JSON.stringify(name)}: ${code}`)
@@ -883,11 +787,7 @@ function getOptions(
883787
inSourceMap = undefined,
884788
forceStringify = false,
885789
isGlobal = false,
886-
bridge = false,
887-
legacy = false,
888-
vueVersion = 'v2.6',
889790
onlyLocales = [],
890-
exportESM = true,
891791
useClassComponent = false,
892792
allowDynamic = false,
893793
strictMessage = true,
@@ -897,11 +797,7 @@ function getOptions(
897797
inSourceMap?: RawSourceMap
898798
forceStringify?: boolean
899799
isGlobal?: boolean
900-
bridge?: boolean
901-
legacy?: boolean
902-
vueVersion?: CodeGenOptions['vueVersion']
903800
onlyLocales?: string[]
904-
exportESM?: boolean
905801
useClassComponent?: boolean
906802
allowDynamic?: boolean
907803
strictMessage?: boolean
@@ -920,12 +816,8 @@ function getOptions(
920816
allowDynamic,
921817
strictMessage,
922818
escapeHtml,
923-
bridge,
924-
legacy,
925-
vueVersion,
926819
jit,
927820
onlyLocales,
928-
exportESM,
929821
env: mode,
930822
onWarn: (msg: string): void => {
931823
warn(`${filename} ${msg}`)

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,9 @@ export interface PluginOptions {
1111
compositionOnly?: boolean
1212
ssr?: boolean
1313
fullInstall?: boolean
14-
esm?: boolean
1514
forceStringify?: boolean
1615
defaultSFCLang?: SFCLangFormat
1716
globalSFCScope?: boolean
18-
bridge?: boolean
19-
legacy?: boolean
20-
vueVersion?: CodeGenOptions['vueVersion']
2117
useClassComponent?: boolean
2218
useVueI18nImportName?: boolean
2319
strictMessage?: boolean

0 commit comments

Comments
 (0)