1
1
/* eslint-disable @typescript-eslint/no-floating-promises */
2
2
import createDebug from 'debug'
3
- import { resolve } from 'pathe'
4
3
import { extendViteConfig , addWebpackPlugin , addBuildPlugin , addTemplate , addRspackPlugin } from '@nuxt/kit'
5
4
import VueI18nPlugin from '@intlify/unplugin-vue-i18n'
6
5
import { toArray } from './utils'
7
6
import { TransformMacroPlugin } from './transform/macros'
8
7
import { ResourcePlugin } from './transform/resource'
9
8
import { TransformI18nFunctionPlugin } from './transform/i18n-function-injection'
10
9
import { asI18nVirtual } from './transform/utils'
11
- import { getLayerLangPaths } from './layers'
12
10
13
11
import type { Nuxt } from '@nuxt/schema'
14
12
import type { PluginOptions } from '@intlify/unplugin-vue-i18n'
@@ -19,13 +17,8 @@ const debug = createDebug('@nuxtjs/i18n:bundler')
19
17
20
18
export async function extendBundler ( ctx : I18nNuxtContext , nuxt : Nuxt ) {
21
19
const { options : nuxtOptions } = ctx
22
- const langPaths = getLayerLangPaths ( nuxt )
23
- debug ( 'langPaths -' , langPaths )
24
- const i18nModulePaths =
25
- nuxtOptions ?. i18nModules ?. map ( module => resolve ( nuxt . options . _layers [ 0 ] . config . rootDir , module . langDir ?? '' ) ) ?? [ ]
26
- debug ( 'i18nModulePaths -' , i18nModulePaths )
27
- const localePaths = [ ...langPaths , ...i18nModulePaths ]
28
- const localeIncludePaths = localePaths . length ? localePaths . map ( x => resolve ( x , './**' ) ) : undefined
20
+ const localePaths = [ ...new Set ( [ ...ctx . localeInfo . flatMap ( x => x . meta ! . map ( m => m . path ) ) ] ) ]
21
+ const localeIncludePaths = localePaths . length ? localePaths : undefined
29
22
30
23
const sourceMapOptions : BundlerPluginOptions = {
31
24
sourcemap : ! ! nuxt . options . sourcemap . server || ! ! nuxt . options . sourcemap . client
0 commit comments