From 4bcb8fa791f5f0460d3c1f00fe3057d4fa7ddd81 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Sun, 18 Apr 2021 18:38:30 +0200 Subject: [PATCH] fix(kit): resolve alias for `installModule` source --- packages/kit/src/module/install.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/kit/src/module/install.ts b/packages/kit/src/module/install.ts index 4ce2fa4415..bf47ad7acc 100644 --- a/packages/kit/src/module/install.ts +++ b/packages/kit/src/module/install.ts @@ -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 }