1- import type { Nuxt } from '@nuxt/schema'
21import {
32 NUXT_I18N_COMPOSABLE_DEFINE_CONFIG ,
43 NUXT_I18N_COMPOSABLE_DEFINE_LOCALE ,
54 NUXT_I18N_COMPOSABLE_DEFINE_ROUTE ,
65 VUE_I18N_PKG
76} from '../constants'
8- import { addComponent , addImports } from '@nuxt/kit'
7+ import { addComponent , addImports , resolveModule } from '@nuxt/kit'
98import { runtimeDir } from '../dirs'
109import type { I18nNuxtContext } from '../context'
1110
12- export function prepareAutoImports ( { debug, resolver } : I18nNuxtContext , nuxt : Nuxt ) {
13- const vueI18nPath = nuxt . options . alias [ VUE_I18N_PKG ]
14- debug ( 'vueI18nPath for auto-import' , vueI18nPath )
15-
11+ export function prepareAutoImports ( { resolver, userOptions : options , isDev, isPrepare } : I18nNuxtContext ) {
1612 addComponent ( {
1713 name : 'NuxtLinkLocale' ,
1814 filePath : resolver . resolve ( runtimeDir , 'components/NuxtLinkLocale' )
@@ -23,8 +19,9 @@ export function prepareAutoImports({ debug, resolver }: I18nNuxtContext, nuxt: N
2319 filePath : resolver . resolve ( runtimeDir , 'components/SwitchLocalePathLink' )
2420 } )
2521
22+ const vueI18nPath = `${ VUE_I18N_PKG } /dist/vue-i18n${ ! isDev && ! isPrepare && options . bundle ?. runtimeOnly ? '.runtime' : '' } .mjs`
2623 addImports ( [
27- { name : 'useI18n' , from : vueI18nPath } ,
24+ { name : 'useI18n' , from : resolveModule ( vueI18nPath ) } ,
2825 ...[
2926 'useRouteBaseName' ,
3027 'useLocalePath' ,
0 commit comments