@@ -18,12 +18,10 @@ import {
18
18
generateYAML ,
19
19
generateJavaScript ,
20
20
checkInstallPackage ,
21
- checkVueI18nBridgeInstallPackage ,
22
21
getVueI18nVersion
23
22
} from '@intlify/bundle-utils'
24
23
import { parse } from '@vue/compiler-sfc'
25
24
import { parseVueRequest , VueQuery } from './query'
26
- import { createBridgeCodeGenerator } from './legacy'
27
25
import { getRaw , warn , error , raiseError } from './utils'
28
26
29
27
import type { RawSourceMap } from 'source-map-js'
@@ -41,7 +39,6 @@ const VIRTUAL_PREFIX = '\0'
41
39
const debug = createDebug ( 'unplugin-vue-i18n' )
42
40
43
41
const installedPkg = checkInstallPackage ( '@intlify/unplugin-vue-i18n' , debug )
44
- const installedVueI18nBridge = checkVueI18nBridgeInstallPackage ( debug )
45
42
const vueI18nVersion = getVueI18nVersion ( debug )
46
43
47
44
if ( vueI18nVersion === '8' ) {
@@ -85,31 +82,6 @@ export const unplugin = createUnplugin<PluginOptions>((options = {}, meta) => {
85
82
const globalSFCScope = ! ! options . globalSFCScope
86
83
const useClassComponent = ! ! options . useClassComponent
87
84
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
-
113
85
const runtimeOnly = isBoolean ( options . runtimeOnly )
114
86
? options . runtimeOnly
115
87
: true
@@ -152,29 +124,21 @@ export const unplugin = createUnplugin<PluginOptions>((options = {}, meta) => {
152
124
153
125
// prettier-ignore
154
126
const getVueI18nAliasName = ( ) =>
155
- vueI18nVersion === '9' || vueI18nVersion === '8'
127
+ vueI18nVersion === '9'
156
128
? 'vue-i18n'
157
129
: vueI18nVersion === 'unknown' && installedPkg === 'petite-vue-i18n' && isBoolean ( useVueI18nImportName ) && useVueI18nImportName
158
130
? 'vue-i18n'
159
131
: installedPkg
160
132
161
- const getVueI18nBridgeAliasPath = ( ) =>
162
- `vue-i18n-bridge/dist/vue-i18n-bridge.runtime.esm-bundler.js`
163
-
164
133
const getVueI18nAliasPath = (
165
134
aliasName : string ,
166
135
{ ssr = false , runtimeOnly = false }
167
136
) => {
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
+ } `
173
140
}
174
141
175
- const esm = isBoolean ( options . esm ) ? options . esm : true
176
- debug ( 'esm' , esm )
177
-
178
142
const allowDynamic = ! ! options . allowDynamic
179
143
debug ( 'allowDynamic' , allowDynamic )
180
144
@@ -221,24 +185,13 @@ export const unplugin = createUnplugin<PluginOptions>((options = {}, meta) => {
221
185
runtimeOnly
222
186
} )
223
187
} )
224
- if ( installedVueI18nBridge ) {
225
- config . resolve ! . alias . push ( {
226
- find : 'vue-i18n-bridge' ,
227
- replacement : getVueI18nBridgeAliasPath ( )
228
- } )
229
- }
230
188
} else if ( isObject ( config . resolve ! . alias ) ) {
231
189
// eslint-disable-next-line @typescript-eslint/no-explicit-any
232
190
; ( config . resolve ! . alias as any ) [ vueI18nAliasName ] =
233
191
getVueI18nAliasPath ( vueI18nAliasName , {
234
192
ssr : ssrBuild ,
235
193
runtimeOnly
236
194
} )
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
- }
242
195
}
243
196
debug (
244
197
`set ${ vueI18nAliasName } runtime only: ${ getVueI18nAliasPath (
@@ -249,11 +202,6 @@ export const unplugin = createUnplugin<PluginOptions>((options = {}, meta) => {
249
202
}
250
203
) } `
251
204
)
252
- if ( installedVueI18nBridge ) {
253
- debug (
254
- `set vue-i18n-bridge runtime only: ${ getVueI18nBridgeAliasPath ( ) } `
255
- )
256
- }
257
205
} else if (
258
206
command === 'serve' &&
259
207
installedPkg === 'petite-vue-i18n' &&
@@ -380,22 +328,14 @@ export const unplugin = createUnplugin<PluginOptions>((options = {}, meta) => {
380
328
allowDynamic,
381
329
strictMessage,
382
330
escapeHtml,
383
- bridge,
384
- legacy,
385
- vueVersion,
386
331
jit : jitCompilation ,
387
332
onlyLocales,
388
- exportESM : esm ,
389
333
forceStringify
390
334
}
391
335
) as CodeGenOptions
392
336
debug ( 'parseOptions' , parseOptions )
393
337
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 )
399
339
debug ( 'generated code' , generatedCode )
400
340
debug ( 'sourcemap' , map , sourceMap )
401
341
@@ -447,22 +387,12 @@ export const unplugin = createUnplugin<PluginOptions>((options = {}, meta) => {
447
387
ssr : ssrBuild ,
448
388
runtimeOnly
449
389
} )
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
- }
455
390
debug (
456
391
`set ${ vueI18nAliasName } : ${ getVueI18nAliasPath ( vueI18nAliasName , {
457
392
ssr : ssrBuild ,
458
393
runtimeOnly
459
394
} ) } `
460
395
)
461
- if ( installedVueI18nBridge ) {
462
- debug (
463
- `set vue-i18n-bridge runtime only: ${ getVueI18nBridgeAliasPath ( ) } `
464
- )
465
- }
466
396
} else if (
467
397
! isProduction &&
468
398
installedPkg === 'petite-vue-i18n' &&
@@ -538,10 +468,8 @@ export const unplugin = createUnplugin<PluginOptions>((options = {}, meta) => {
538
468
isProduction ,
539
469
{
540
470
forceStringify,
541
- bridge,
542
471
strictMessage,
543
472
escapeHtml,
544
- exportESM : esm ,
545
473
useClassComponent
546
474
}
547
475
)
@@ -593,20 +521,14 @@ export const unplugin = createUnplugin<PluginOptions>((options = {}, meta) => {
593
521
allowDynamic,
594
522
strictMessage,
595
523
escapeHtml,
596
- bridge,
597
524
jit : jitCompilation ,
598
525
onlyLocales,
599
- exportESM : esm ,
600
526
forceStringify
601
527
}
602
528
) as CodeGenOptions
603
529
debug ( 'parseOptions' , parseOptions )
604
530
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 )
610
532
debug ( 'generated code' , generatedCode )
611
533
debug ( 'sourcemap' , map , sourceMap )
612
534
@@ -654,14 +576,10 @@ export const unplugin = createUnplugin<PluginOptions>((options = {}, meta) => {
654
576
inSourceMap,
655
577
isGlobal : globalSFCScope ,
656
578
useClassComponent,
657
- bridge,
658
- legacy,
659
- vueVersion,
660
579
jit : jitCompilation ,
661
580
strictMessage,
662
581
escapeHtml,
663
582
onlyLocales,
664
- exportESM : esm ,
665
583
forceStringify
666
584
}
667
585
) as CodeGenOptions
@@ -674,11 +592,7 @@ export const unplugin = createUnplugin<PluginOptions>((options = {}, meta) => {
674
592
query ,
675
593
meta . framework
676
594
)
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 )
682
596
debug ( 'generated code' , generatedCode )
683
597
debug ( 'sourcemap' , map , sourceMap )
684
598
@@ -753,19 +667,15 @@ async function generateBundleResources(
753
667
{
754
668
forceStringify = false ,
755
669
isGlobal = false ,
756
- bridge = false ,
757
670
onlyLocales = [ ] ,
758
- exportESM = true ,
759
671
strictMessage = true ,
760
672
escapeHtml = false ,
761
673
useClassComponent = false ,
762
674
jit = false
763
675
} : {
764
676
forceStringify ?: boolean
765
677
isGlobal ?: boolean
766
- bridge ?: boolean
767
678
onlyLocales ?: string [ ]
768
- exportESM ?: boolean
769
679
strictMessage ?: boolean
770
680
escapeHtml ?: boolean
771
681
useClassComponent ?: boolean
@@ -783,20 +693,14 @@ async function generateBundleResources(
783
693
const parseOptions = getOptions ( res , isProduction , { } , false , {
784
694
isGlobal,
785
695
useClassComponent,
786
- bridge,
787
696
jit,
788
697
onlyLocales,
789
- exportESM,
790
698
strictMessage,
791
699
escapeHtml,
792
700
forceStringify
793
701
} ) as CodeGenOptions
794
702
parseOptions . type = 'bare'
795
- const { code } = generate (
796
- source ,
797
- parseOptions ,
798
- bridge ? createBridgeCodeGenerator ( source , query ) : undefined
799
- )
703
+ const { code } = generate ( source , parseOptions )
800
704
801
705
debug ( 'generated code' , code )
802
706
codes . push ( `${ JSON . stringify ( name ) } : ${ code } ` )
@@ -883,11 +787,7 @@ function getOptions(
883
787
inSourceMap = undefined ,
884
788
forceStringify = false ,
885
789
isGlobal = false ,
886
- bridge = false ,
887
- legacy = false ,
888
- vueVersion = 'v2.6' ,
889
790
onlyLocales = [ ] ,
890
- exportESM = true ,
891
791
useClassComponent = false ,
892
792
allowDynamic = false ,
893
793
strictMessage = true ,
@@ -897,11 +797,7 @@ function getOptions(
897
797
inSourceMap ?: RawSourceMap
898
798
forceStringify ?: boolean
899
799
isGlobal ?: boolean
900
- bridge ?: boolean
901
- legacy ?: boolean
902
- vueVersion ?: CodeGenOptions [ 'vueVersion' ]
903
800
onlyLocales ?: string [ ]
904
- exportESM ?: boolean
905
801
useClassComponent ?: boolean
906
802
allowDynamic ?: boolean
907
803
strictMessage ?: boolean
@@ -920,12 +816,8 @@ function getOptions(
920
816
allowDynamic,
921
817
strictMessage,
922
818
escapeHtml,
923
- bridge,
924
- legacy,
925
- vueVersion,
926
819
jit,
927
820
onlyLocales,
928
- exportESM,
929
821
env : mode ,
930
822
onWarn : ( msg : string ) : void => {
931
823
warn ( `${ filename } ${ msg } ` )
0 commit comments