diff --git a/.changeset/nice-crews-beg.md b/.changeset/nice-crews-beg.md new file mode 100644 index 00000000000..1fbea3abe63 --- /dev/null +++ b/.changeset/nice-crews-beg.md @@ -0,0 +1,5 @@ +--- +'@module-federation/modern-js': patch +--- + +fix(modernjs): auto set enableAsyncEntry when bundler is rspack diff --git a/packages/modernjs/src/cli/configPlugin.ts b/packages/modernjs/src/cli/configPlugin.ts index 125af5b49c2..e816c5e13cf 100644 --- a/packages/modernjs/src/cli/configPlugin.ts +++ b/packages/modernjs/src/cli/configPlugin.ts @@ -127,6 +127,10 @@ export const moduleFederationConfigPlugin = ( FEDERATION_IPV4: JSON.stringify(ipv4), REMOTE_IP_STRATEGY: JSON.stringify(userConfig.remoteIpStrategy), }, + enableAsyncEntry: + bundlerType === 'rspack' + ? modernjsConfig.source?.enableAsyncEntry ?? true + : modernjsConfig.source?.enableAsyncEntry, }, dev: { assetPrefix: modernjsConfig?.dev?.assetPrefix diff --git a/packages/modernjs/src/cli/ssrPlugin.ts b/packages/modernjs/src/cli/ssrPlugin.ts index 0f90dc809f8..aaa12583792 100644 --- a/packages/modernjs/src/cli/ssrPlugin.ts +++ b/packages/modernjs/src/cli/ssrPlugin.ts @@ -42,16 +42,7 @@ export const moduleFederationSSRPlugin = ( return { entrypoint, plugins }; }, config: async () => { - const bundlerType = - useAppContext().bundlerType === 'rspack' ? 'rspack' : 'webpack'; - return { - source: { - enableAsyncEntry: - bundlerType === 'rspack' - ? modernjsConfig.source?.enableAsyncEntry ?? true - : modernjsConfig.source?.enableAsyncEntry, - }, tools: { rspack(config, { isServer }) { if (isServer) {