Skip to content

Commit

Permalink
Merge pull request #239 from modern-js-dev/fix/remote-externals
Browse files Browse the repository at this point in the history
fix(remoteModule): merge global externals bug
  • Loading branch information
imtaotao authored Oct 19, 2021
2 parents e644e18 + cdecb3e commit 79cb86d
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions packages/remote-module/src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down

0 comments on commit 79cb86d

Please sign in to comment.