mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
fix(kit): avoid fallback to normalized path in module loading (#27507)
This commit is contained in:
parent
22cd4770c1
commit
da28077be3
@ -84,7 +84,7 @@ export async function loadNuxtModuleInstance (nuxtModule: string | NuxtModule, n
|
||||
let error: unknown
|
||||
for (const path of paths) {
|
||||
try {
|
||||
const src = await resolvePath(path)
|
||||
const src = await resolvePath(path, { fallbackToOriginal: true })
|
||||
// Prefer ESM resolution if possible
|
||||
nuxtModule = await importModule(src, nuxt.options.modulesDir).catch(() => null) ?? requireModule(src, { paths: nuxt.options.modulesDir })
|
||||
|
||||
|
@ -23,6 +23,13 @@ export interface ResolvePathOptions {
|
||||
* @default false
|
||||
*/
|
||||
virtual?: boolean
|
||||
|
||||
/**
|
||||
* Whether to fallback to the original path if the resolved path does not exist instead of returning the normalized input path.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
fallbackToOriginal?: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
@ -99,7 +106,7 @@ export async function resolvePath (path: string, opts: ResolvePathOptions = {}):
|
||||
}
|
||||
|
||||
// Return normalized input
|
||||
return path
|
||||
return opts.fallbackToOriginal ? _path : path
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user