Skip to content

Commit

Permalink
fix: could not resolve module (#2587)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfriesen authored Dec 3, 2023
1 parent 9f91b59 commit bcd6198
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/alias.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {
MESSAGE_COMPILER_PKG,
CORE_BASE_PKG,
UFO_PKG,
IS_HTTPS_PKG
IS_HTTPS_PKG,
NUXT_I18N_MODULE_ID
} from './constants'

import type { Nuxt } from '@nuxt/schema'
Expand All @@ -34,8 +35,11 @@ export async function setupAlias(nuxt: Nuxt, options: NuxtI18nOptions) {
modules[UFO_PKG] = UFO_PKG
modules[IS_HTTPS_PKG] = IS_HTTPS_PKG

const moduleDirs: string[] = nuxt.options.modulesDir || []
const enhancedModulesDirs = [...moduleDirs, ...moduleDirs.map(dir => `${dir}/${NUXT_I18N_MODULE_ID}/node_modules`)]

for (const [moduleName, moduleFile] of Object.entries(modules)) {
const module = await tryResolveModule(moduleFile, nuxt.options.modulesDir)
const module = await tryResolveModule(moduleFile, enhancedModulesDirs)
if (!module) throw new Error(`Could not resolve module "${moduleFile}"`)
nuxt.options.alias[moduleName] = module
nuxt.options.build.transpile.push(moduleName)
Expand Down

0 comments on commit bcd6198

Please sign in to comment.