diff --git a/.changeset/lemon-fans-tickle.md b/.changeset/lemon-fans-tickle.md new file mode 100644 index 00000000000..43bb93748fe --- /dev/null +++ b/.changeset/lemon-fans-tickle.md @@ -0,0 +1,5 @@ +--- +'@module-federation/enhanced': patch +--- + +fix: not duplicate set resolve.alias diff --git a/packages/enhanced/src/lib/container/runtime/FederationRuntimePlugin.ts b/packages/enhanced/src/lib/container/runtime/FederationRuntimePlugin.ts index b9e6d460799..4d6c93a56ff 100644 --- a/packages/enhanced/src/lib/container/runtime/FederationRuntimePlugin.ts +++ b/packages/enhanced/src/lib/container/runtime/FederationRuntimePlugin.ts @@ -205,13 +205,22 @@ class FederationRuntimePlugin { paths: [this.options.implementation], }); } + if (Array.isArray(compiler.options.resolve.alias)) { + return; + } compiler.options.resolve.alias = { ...compiler.options.resolve.alias, - '@module-federation/runtime$': runtimePath, - '@module-federation/runtime-tools$': - this.options?.implementation || RuntimeToolsPath, }; + + if (!compiler.options.resolve.alias['@module-federation/runtime$']) { + compiler.options.resolve.alias['@module-federation/runtime$'] = + runtimePath; + } + if (!compiler.options.resolve.alias['@module-federation/runtime-tools$']) { + compiler.options.resolve.alias['@module-federation/runtime-tools$'] = + this.options?.implementation || RuntimeToolsPath; + } } apply(compiler: Compiler) {