From e7424c2bff816515fea726f25538ece5bf06d7a7 Mon Sep 17 00:00:00 2001 From: jimmiezhang Date: Thu, 9 Jun 2022 14:45:34 +0800 Subject: [PATCH] fix: plugin path (#101) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: plugin path * chore: plugin package.json * chore: del path * chore: find importPath use path.resolve+require.resolve Co-authored-by: 张荣杰 --- src/plugin/base.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugin/base.ts b/src/plugin/base.ts index db83659..84be67b 100644 --- a/src/plugin/base.ts +++ b/src/plugin/base.ts @@ -1,4 +1,5 @@ import { Plugin, PluginConfigItem, PluginMetadata } from "./types"; +import path from 'path'; type PluginMap = Map; export class BasePlugin implements Plugin { @@ -12,7 +13,7 @@ export class BasePlugin implements Plugin { this.name = name; let importPath = configItem.path ?? ''; if (configItem.package) { - importPath = require.resolve(configItem.package); + importPath = path.resolve(require.resolve(`${configItem.package}/package.json`), '..'); } if (!importPath) { throw new Error(`Plugin ${name} need have path or package field`);