Skip to content

Commit bf45cf6

Browse files
authored
fix: only force split async chunks when format is esm or cjs (#1152)
1 parent 477004d commit bf45cf6

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed

packages/core/src/config.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -513,10 +513,6 @@ export async function createConstantRsbuildConfig(): Promise<EnvironmentConfig>
513513
htmlPlugin: false,
514514
rspack: {
515515
optimization: {
516-
splitChunks: {
517-
// Splitted "sync" chunks will make entry modules can't be inlined.
518-
chunks: 'async',
519-
},
520516
moduleIds: 'named',
521517
nodeEnv: false,
522518
},
@@ -604,6 +600,10 @@ const composeFormatConfig = ({
604600
concatenateModules: true,
605601
sideEffects: 'flag',
606602
avoidEntryIife: true,
603+
splitChunks: {
604+
// Splitted "sync" chunks will make entry modules can't be inlined.
605+
chunks: 'async',
606+
},
607607
},
608608
output: {
609609
module: true,
@@ -634,6 +634,12 @@ const composeFormatConfig = ({
634634
},
635635
},
636636
},
637+
optimization: {
638+
splitChunks: {
639+
// Splitted "sync" chunks will make entry modules can't be inlined.
640+
chunks: 'async',
641+
},
642+
},
637643
output: {
638644
iife: false,
639645
chunkFormat: 'commonjs',

packages/core/tests/__snapshots__/config.test.ts.snap

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,6 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
157157
"optimization": {
158158
"moduleIds": "named",
159159
"nodeEnv": false,
160-
"splitChunks": {
161-
"chunks": "async",
162-
},
163160
},
164161
"resolve": {
165162
"extensionAlias": {
@@ -208,6 +205,9 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
208205
"avoidEntryIife": true,
209206
"concatenateModules": true,
210207
"sideEffects": "flag",
208+
"splitChunks": {
209+
"chunks": "async",
210+
},
211211
},
212212
"output": {
213213
"chunkFormat": "module",
@@ -434,9 +434,6 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
434434
"optimization": {
435435
"moduleIds": "named",
436436
"nodeEnv": false,
437-
"splitChunks": {
438-
"chunks": "async",
439-
},
440437
},
441438
"resolve": {
442439
"extensionAlias": {
@@ -474,6 +471,11 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
474471
},
475472
},
476473
},
474+
"optimization": {
475+
"splitChunks": {
476+
"chunks": "async",
477+
},
478+
},
477479
"output": {
478480
"chunkFormat": "commonjs",
479481
"chunkLoading": "require",
@@ -668,9 +670,6 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
668670
"optimization": {
669671
"moduleIds": "named",
670672
"nodeEnv": false,
671-
"splitChunks": {
672-
"chunks": "async",
673-
},
674673
},
675674
"resolve": {
676675
"extensionAlias": {
@@ -898,9 +897,6 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
898897
"optimization": {
899898
"moduleIds": "named",
900899
"nodeEnv": false,
901-
"splitChunks": {
902-
"chunks": "async",
903-
},
904900
},
905901
"resolve": {
906902
"extensionAlias": {
@@ -1085,9 +1081,6 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
10851081
"optimization": {
10861082
"moduleIds": "named",
10871083
"nodeEnv": false,
1088-
"splitChunks": {
1089-
"chunks": "async",
1090-
},
10911084
},
10921085
"resolve": {
10931086
"extensionAlias": {

0 commit comments

Comments
 (0)