mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-16 21:58:19 +00:00
refactor(nuxt): let mlly handle search paths (#19635)
This commit is contained in:
parent
8051614738
commit
ce45590120
@ -7,13 +7,13 @@ import { interopDefault, resolvePath } from 'mlly'
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export async function tryResolveModule (id: string, url = import.meta.url) {
|
||||
export async function tryResolveModule (id: string, url: string | string[] = import.meta.url) {
|
||||
try {
|
||||
return await resolvePath(id, { url })
|
||||
} catch { }
|
||||
}
|
||||
|
||||
export async function importModule (id: string, url = import.meta.url) {
|
||||
export async function importModule (id: string, url: string | string[] = import.meta.url) {
|
||||
const resolvedPath = await resolvePath(id, { url })
|
||||
return import(pathToFileURL(resolvedPath).href).then(interopDefault)
|
||||
}
|
||||
|
@ -80,10 +80,8 @@ async function bundle (nuxt: Nuxt) {
|
||||
}
|
||||
|
||||
async function loadBuilder (nuxt: Nuxt, builder: string) {
|
||||
for (const root of [nuxt.options.rootDir, import.meta.url]) {
|
||||
const builderPath = await tryResolveModule(builder, root)
|
||||
if (builderPath) {
|
||||
return import(builderPath)
|
||||
}
|
||||
const builderPath = await tryResolveModule(builder, [nuxt.options.rootDir, import.meta.url])
|
||||
if (builderPath) {
|
||||
return import(builderPath)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user