From cdecb3e42e3c13504da69c221f41913851a3b74e Mon Sep 17 00:00:00 2001 From: "chentao.arthur" Date: Tue, 19 Oct 2021 16:15:15 +0800 Subject: [PATCH] fix(remoteModule): merge global externals bug --- packages/remote-module/src/common.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/remote-module/src/common.ts b/packages/remote-module/src/common.ts index 023e219ee..f887dc2dc 100644 --- a/packages/remote-module/src/common.ts +++ b/packages/remote-module/src/common.ts @@ -79,17 +79,22 @@ export const getModuleCode = (url: string) => { export const purifyOptions = (urlOrAlias: string, options?: ModuleInfo) => { let config; + const globalExternals = moduleConfig.externals; + delete moduleConfig.externals; if (isPlainObject(options)) { - const cloned = { ...options }; - const externals = { ...moduleConfig.externals, ...options.externals }; - delete cloned.externals; - config = deepMerge(moduleConfig, { ...cloned, url: urlOrAlias }); - config.externals = externals; + const curExternals = options.externals; + delete options.externals; + config = deepMerge(moduleConfig, { ...options, url: urlOrAlias }); + options.externals = curExternals; + config.externals = { ...globalExternals, ...curExternals }; } else { config = deepMerge(moduleConfig, { url: urlOrAlias }); + config.externals = globalExternals; } + moduleConfig.externals = globalExternals; + return config as ModuleInfo & { url: string; };