From 5ece6882e828e40d9a07d59a28352b72425d8b1a Mon Sep 17 00:00:00 2001 From: Noah Gao Date: Tue, 21 Feb 2023 22:23:55 +0800 Subject: [PATCH] fix(plugin): prevent require.resolve paths arguments undefined (#231) --- src/plugin/factory.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugin/factory.ts b/src/plugin/factory.ts index e529013..b0f2e5b 100644 --- a/src/plugin/factory.ts +++ b/src/plugin/factory.ts @@ -46,7 +46,8 @@ export class PluginFactory { `Plugin ${pluginName} config can't have both package and path at ${manifestItem?.path ?? 'UNKNOWN_PATH'}`, ); } - pluginConfigItem.path = getPackagePath(pluginConfigItem.package, [loaderState?.baseDir]); + const requirePaths = loaderState?.baseDir ? [loaderState.baseDir] : undefined; + pluginConfigItem.path = getPackagePath(pluginConfigItem.package, requirePaths); delete pluginConfigItem.package; } else if (pluginConfigItem.path && await exists(path.resolve(pluginConfigItem.path, 'package.json'))) { // plugin path is a npm package, need resolve main file