mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 23:22:02 +00:00
refactor(kit): use esm utils for resolvePath
(#20756)
This commit is contained in:
parent
3b820ad366
commit
cbcd254cd4
@ -94,18 +94,6 @@ export function resolveModule (id: string, opts: ResolveModuleOptions = {}) {
|
||||
}))
|
||||
}
|
||||
|
||||
/** @deprecated Do not use CJS utils */
|
||||
export function tryResolveModule (path: string, opts: ResolveModuleOptions = {}): string | null {
|
||||
try {
|
||||
return resolveModule(path, opts)
|
||||
} catch (error: any) {
|
||||
if (error?.code !== 'MODULE_NOT_FOUND') {
|
||||
throw error
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
/** @deprecated Do not use CJS utils */
|
||||
export function requireModule (id: string, opts: RequireModuleOptions = {}) {
|
||||
// Resolve id
|
||||
|
@ -2,9 +2,9 @@ import { existsSync, promises as fsp } from 'node:fs'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { basename, dirname, isAbsolute, join, normalize, resolve } from 'pathe'
|
||||
import { globby } from 'globby'
|
||||
import { resolvePath as _resolvePath } from 'mlly'
|
||||
import { resolveAlias as _resolveAlias } from 'pathe/utils'
|
||||
import { tryUseNuxt } from './context'
|
||||
import { tryResolveModule } from './internal/cjs'
|
||||
import { isIgnored } from './ignore'
|
||||
|
||||
export interface ResolvePathOptions {
|
||||
@ -71,7 +71,7 @@ export async function resolvePath (path: string, opts: ResolvePathOptions = {}):
|
||||
}
|
||||
|
||||
// Try to resolve as module id
|
||||
const resolveModulePath = tryResolveModule(_path, { paths: [cwd, ...modulesDir] })
|
||||
const resolveModulePath = await _resolvePath(_path, { url: [cwd, ...modulesDir] }).catch(() => null)
|
||||
if (resolveModulePath) {
|
||||
return resolveModulePath
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user