diff --git a/packages/core/app/client/.umirc.ts b/packages/core/app/client/.umirc.ts index 1b828cb3e..1b0cd40bd 100644 --- a/packages/core/app/client/.umirc.ts +++ b/packages/core/app/client/.umirc.ts @@ -10,7 +10,7 @@ process.env.DID_YOU_KNOW = 'none'; const pluginPrefix = (process.env.PLUGIN_PACKAGE_PREFIX || '').split(',').filter((item) => !item.includes('preset')); // 因为现在 preset 是直接引入的,所以不能忽略,如果以后 preset 也是动态插件的形式引入,那么这里可以去掉 const pluginDirs = (process.env.PLUGIN_PATH || 'packages/plugins/,packages/samples/,packages/pro-plugins/') - .split(',').map(item => path.join(__dirname, '..', '..', '..', '..', item)); + .split(',').map(item => path.join(process.cwd(), item)); const outputPluginPath = path.join(__dirname, 'src', '.plugins'); const indexGenerator = new IndexGenerator(outputPluginPath, pluginDirs); diff --git a/packages/core/client/src/application/utils/remotePlugins.ts b/packages/core/client/src/application/utils/remotePlugins.ts index 221e16844..fef3d1521 100644 --- a/packages/core/client/src/application/utils/remotePlugins.ts +++ b/packages/core/client/src/application/utils/remotePlugins.ts @@ -79,31 +79,27 @@ export async function getPlugins(options: GetPluginsOption): Promise = []; + const res: Array<[string, typeof Plugin]> = []; - const resolveDevPlugins: Record = {}; - if (devDynamicImport) { - for await (const plugin of pluginData) { - const pluginModule = await devDynamicImport(plugin.packageName); - if (pluginModule) { - res.push([plugin.name, pluginModule.default]); - resolveDevPlugins[plugin.packageName] = pluginModule.default; - } + const resolveDevPlugins: Record = {}; + if (devDynamicImport) { + for await (const plugin of pluginData) { + const pluginModule = await devDynamicImport(plugin.packageName); + if (pluginModule) { + res.push([plugin.name, pluginModule.default]); + resolveDevPlugins[plugin.packageName] = pluginModule.default; } - defineDevPlugins(resolveDevPlugins); } + defineDevPlugins(resolveDevPlugins); + } - const remotePlugins = pluginData.filter((item) => !resolveDevPlugins[item.packageName]); + const remotePlugins = pluginData.filter((item) => !resolveDevPlugins[item.packageName]); - if (remotePlugins.length === 0) { - return res; - } - - const remotePluginList = await getRemotePlugins(requirejs, remotePlugins); - res.push(...remotePluginList); + if (remotePlugins.length === 0) { return res; } - return getRemotePlugins(requirejs, pluginData); + const remotePluginList = await getRemotePlugins(requirejs, remotePlugins); + res.push(...remotePluginList); + return res; } diff --git a/yarn.lock b/yarn.lock index 3a6221c2d..a053c3d2e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -15391,11 +15391,6 @@ jest_workaround@^0.79.19: resolved "https://registry.npmmirror.com/jest_workaround/-/jest_workaround-0.79.19.tgz#f5bc569163c33c4533e1c4053c533a8811152a91" integrity sha512-g/MtKSwyb4Ohnd5GHeJaduTgznkyst81x+eUBGOSGK7f8doWuRMPpt6XM/13sM2jLB2QNzT/7Djj7o2PhsozIA== -jmespath@^0.16.0: - version "0.16.0" - resolved "https://registry.npmmirror.com/jmespath/-/jmespath-0.16.0.tgz#b15b0a85dfd4d930d43e69ed605943c802785076" - integrity sha512-9FzQjJ7MATs1tSpnco1K6ayiYE3figslrXA72G2HQ/n76RzvYlofyi5QM+iX4YRs/pu3yzxlVQSST23+dMDknw== - jose@^4.14.1: version "4.14.4" resolved "https://registry.npmmirror.com/jose/-/jose-4.14.4.tgz#59e09204e2670c3164ee24cbfe7115c6f8bff9ca" @@ -15547,11 +15542,6 @@ json5@^2.1.2, json5@^2.2.2, json5@^2.2.3: version "2.2.3" resolved "https://registry.npmmirror.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283" -jsonata@^2.0.3: - version "2.0.3" - resolved "https://registry.npmmirror.com/jsonata/-/jsonata-2.0.3.tgz#f8971c2891cb1d6ebfeecbfe657ecc38c1b843a5" - integrity sha512-Up2H81MUtjqI/dWwWX7p4+bUMfMrQJVMN/jW6clFMTiYP528fBOBNtRu944QhKTs3+IsVWbgMeUTny5fw2VMUA== - jsonc-parser@^3.2.0: version "3.2.0" resolved "https://registry.npmmirror.com/jsonc-parser/-/jsonc-parser-3.2.0.tgz#31ff3f4c2b9793f89c67212627c51c6394f88e76" @@ -15580,11 +15570,6 @@ jsonparse@^1.2.0, jsonparse@^1.3.1: version "1.3.1" resolved "https://registry.npmmirror.com/jsonparse/-/jsonparse-1.3.1.tgz#3f4dae4a91fac315f71062f8521cc239f1366280" -jsonpath-plus@^7.2.0: - version "7.2.0" - resolved "https://registry.npmmirror.com/jsonpath-plus/-/jsonpath-plus-7.2.0.tgz#7ad94e147b3ed42f7939c315d2b9ce490c5a3899" - integrity sha512-zBfiUPM5nD0YZSBT/o/fbCUlCcepMIdP0CJZxM1+KgA4f2T206f6VAg9e7mX35+KlMaIc5qXW34f3BnwJ3w+RA== - jsonwebtoken@^8.5.1: version "8.5.1" resolved "https://registry.npmmirror.com/jsonwebtoken/-/jsonwebtoken-8.5.1.tgz#00e71e0b8df54c2121a1f26137df2280673bcc0d"