@@ -17,8 +17,7 @@ import {
17
17
generateJSON ,
18
18
generateYAML ,
19
19
generateJavaScript ,
20
- checkInstallPackage ,
21
- getVueI18nVersion
20
+ checkInstallPackage
22
21
} from '@intlify/bundle-utils'
23
22
import { parse } from '@vue/compiler-sfc'
24
23
import { parseVueRequest , VueQuery } from './query'
@@ -39,7 +38,6 @@ const VIRTUAL_PREFIX = '\0'
39
38
const debug = createDebug ( 'unplugin-vue-i18n' )
40
39
41
40
const installedPkg = checkInstallPackage ( '@intlify/unplugin-vue-i18n' , debug )
42
- const vueI18nVersion = getVueI18nVersion ( debug )
43
41
44
42
export const unplugin = createUnplugin < PluginOptions > ( ( options = { } , meta ) => {
45
43
debug ( 'plugin options:' , options , meta . framework )
@@ -112,17 +110,12 @@ export const unplugin = createUnplugin<PluginOptions>((options = {}, meta) => {
112
110
113
111
// prettier-ignore
114
112
const getVueI18nAliasName = ( ) =>
115
- vueI18nVersion === '9'
113
+ installedPkg === 'petite-vue-i18n' && isBoolean ( useVueI18nImportName ) && useVueI18nImportName
116
114
? 'vue-i18n'
117
- : vueI18nVersion === 'unknown' && installedPkg === 'petite-vue-i18n' && isBoolean ( useVueI18nImportName ) && useVueI18nImportName
118
- ? 'vue-i18n'
119
- : installedPkg
120
-
121
- const getVueI18nAliasPath = (
122
- aliasName : string ,
123
- { ssr = false , runtimeOnly = false }
124
- ) => {
125
- return `${ aliasName } /dist/${ installedPkg } ${ runtimeOnly ? '.runtime' : '' } .${
115
+ : installedPkg
116
+
117
+ const getVueI18nAliasPath = ( { ssr = false , runtimeOnly = false } ) => {
118
+ return `${ installedPkg } /dist/${ installedPkg } ${ runtimeOnly ? '.runtime' : '' } .${
126
119
! ssr ? 'esm-bundler.js' /* '.mjs' */ : 'node.mjs'
127
120
} `
128
121
}
@@ -168,27 +161,24 @@ export const unplugin = createUnplugin<PluginOptions>((options = {}, meta) => {
168
161
if ( isArray ( config . resolve ! . alias ) ) {
169
162
config . resolve ! . alias . push ( {
170
163
find : vueI18nAliasName ,
171
- replacement : getVueI18nAliasPath ( vueI18nAliasName , {
164
+ replacement : getVueI18nAliasPath ( {
172
165
ssr : ssrBuild ,
173
166
runtimeOnly
174
167
} )
175
168
} )
176
169
} else if ( isObject ( config . resolve ! . alias ) ) {
177
170
// eslint-disable-next-line @typescript-eslint/no-explicit-any
178
171
; ( config . resolve ! . alias as any ) [ vueI18nAliasName ] =
179
- getVueI18nAliasPath ( vueI18nAliasName , {
172
+ getVueI18nAliasPath ( {
180
173
ssr : ssrBuild ,
181
174
runtimeOnly
182
175
} )
183
176
}
184
177
debug (
185
- `set ${ vueI18nAliasName } runtime only: ${ getVueI18nAliasPath (
186
- vueI18nAliasName ,
187
- {
188
- ssr : ssrBuild ,
189
- runtimeOnly
190
- }
191
- ) } `
178
+ `set ${ vueI18nAliasName } runtime only: ${ getVueI18nAliasPath ( {
179
+ ssr : ssrBuild ,
180
+ runtimeOnly
181
+ } ) } `
192
182
)
193
183
} else if (
194
184
command === 'serve' &&
@@ -360,12 +350,12 @@ export const unplugin = createUnplugin<PluginOptions>((options = {}, meta) => {
360
350
if ( isProduction ) {
361
351
// eslint-disable-next-line @typescript-eslint/no-explicit-any
362
352
; ( compiler . options . resolve ! . alias as any ) [ vueI18nAliasName ] =
363
- getVueI18nAliasPath ( vueI18nAliasName , {
353
+ getVueI18nAliasPath ( {
364
354
ssr : ssrBuild ,
365
355
runtimeOnly
366
356
} )
367
357
debug (
368
- `set ${ vueI18nAliasName } : ${ getVueI18nAliasPath ( vueI18nAliasName , {
358
+ `set ${ vueI18nAliasName } : ${ getVueI18nAliasPath ( {
369
359
ssr : ssrBuild ,
370
360
runtimeOnly
371
361
} ) } `
0 commit comments