mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 13:45:18 +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
|
let error: unknown
|
||||||
for (const path of paths) {
|
for (const path of paths) {
|
||||||
try {
|
try {
|
||||||
const src = await resolvePath(path)
|
const src = await resolvePath(path, { fallbackToOriginal: true })
|
||||||
// Prefer ESM resolution if possible
|
// Prefer ESM resolution if possible
|
||||||
nuxtModule = await importModule(src, nuxt.options.modulesDir).catch(() => null) ?? requireModule(src, { paths: nuxt.options.modulesDir })
|
nuxtModule = await importModule(src, nuxt.options.modulesDir).catch(() => null) ?? requireModule(src, { paths: nuxt.options.modulesDir })
|
||||||
|
|
||||||
|
@ -23,6 +23,13 @@ export interface ResolvePathOptions {
|
|||||||
* @default false
|
* @default false
|
||||||
*/
|
*/
|
||||||
virtual?: boolean
|
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 normalized input
|
||||||
return path
|
return opts.fallbackToOriginal ? _path : path
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user