diff --git a/packages/core/src/config.ts b/packages/core/src/config.ts index f03b2b253..90713a1e3 100644 --- a/packages/core/src/config.ts +++ b/packages/core/src/config.ts @@ -718,6 +718,10 @@ const composeFormatConfig = ({ }, optimization: { nodeEnv: process.env.NODE_ENV, + splitChunks: { + // sync chunk of umd can not be loaded without mounting on scripts + chunks: 'async', + }, }, plugins, }, diff --git a/packages/core/tests/__snapshots__/config.test.ts.snap b/packages/core/tests/__snapshots__/config.test.ts.snap index 87585b114..b0549800d 100644 --- a/packages/core/tests/__snapshots__/config.test.ts.snap +++ b/packages/core/tests/__snapshots__/config.test.ts.snap @@ -2201,7 +2201,9 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i }, optimization: { minimize: true, - splitChunks: false, + splitChunks: { + chunks: 'async' + }, minimizer: [ /* config.optimization.minimizer('js') */ new SwcJsMinimizerRspackPlugin( @@ -4154,6 +4156,9 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i }, "optimization": { "nodeEnv": undefined, + "splitChunks": { + "chunks": "async", + }, }, "output": { "asyncChunks": false,