fix(kit): resolve alias for installModule source

This commit is contained in:
Pooya Parsa 2021-04-18 18:38:30 +02:00
parent 7ee7a7a7b5
commit 4bcb8fa791

View File

@ -1,6 +1,7 @@
import type { Nuxt } from '../types/nuxt'
import type { LegacyNuxtModule, NuxtModule, ModuleMeta, ModuleInstallOptions, ModuleOptions, ModuleSrc } from '../types/module'
import { requireModule } from '../utils/cjs'
import { resolveModule, requireModule } from '../utils/cjs'
import { resolveAlias } from '../utils/resolve'
import { nuxtCtx } from '../nuxt'
import { defineNuxtModule } from './define'
import { ModuleContainer } from './container'
@ -31,7 +32,8 @@ export async function installModule (nuxt: Nuxt, installOpts: ModuleInstallOptio
// Resolve as legacy handler
let handler: LegacyNuxtModule
if (typeof src === 'string') {
handler = requireModule(src)
const _src = resolveModule(resolveAlias(src, nuxt.options.alias), { paths: nuxt.options.modulesDir })
handler = requireModule(_src)
if (!meta.name) {
meta.name = src
}