mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 05:35:13 +00:00
fix(kit): convert module path to file url before reading meta
This commit is contained in:
parent
8feafa9554
commit
5fa566c09a
@ -84,13 +84,13 @@ export async function loadNuxtModuleInstance (nuxtModule: string | NuxtModule, n
|
|||||||
try {
|
try {
|
||||||
const resolved = resolveAlias(path, nuxt.options.alias)
|
const resolved = resolveAlias(path, nuxt.options.alias)
|
||||||
const src = isAbsolute(resolved)
|
const src = isAbsolute(resolved)
|
||||||
? await resolvePath(resolved, { cwd: parentURL, fallbackToOriginal: false, extensions: nuxt.options.extensions })
|
? pathToFileURL(await resolvePath(resolved, { cwd: parentURL, fallbackToOriginal: false, extensions: nuxt.options.extensions })).href
|
||||||
: await resolveModule(resolved, { url: pathToFileURL(parentURL.replace(/\/node_modules\/?$/, '')), extensions: nuxt.options.extensions })
|
: await resolveModule(resolved, { url: pathToFileURL(parentURL.replace(/\/node_modules\/?$/, '')), extensions: nuxt.options.extensions })
|
||||||
|
|
||||||
nuxtModule = await jiti.import(src, { default: true }) as NuxtModule
|
nuxtModule = await jiti.import(src, { default: true }) as NuxtModule
|
||||||
|
|
||||||
// nuxt-module-builder generates a module.json with metadata including the version
|
// nuxt-module-builder generates a module.json with metadata including the version
|
||||||
const moduleMetadataPath = join(dirname(src), 'module.json')
|
const moduleMetadataPath = new URL('module.json', src)
|
||||||
if (existsSync(moduleMetadataPath)) {
|
if (existsSync(moduleMetadataPath)) {
|
||||||
buildTimeModuleMeta = JSON.parse(await fsp.readFile(moduleMetadataPath, 'utf-8'))
|
buildTimeModuleMeta = JSON.parse(await fsp.readFile(moduleMetadataPath, 'utf-8'))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user