Skip to content

Commit c6482d5

Browse files
authored
feat: enable inline const optimization by default (#6043)
1 parent 2bc6e1d commit c6482d5

File tree

6 files changed

+24
-0
lines changed

6 files changed

+24
-0
lines changed

packages/compat/webpack/tests/__snapshots__/default.test.ts.snap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ exports[`applyDefaultPlugins > should apply default plugins correctly 1`] = `
3333
"parser": {
3434
"javascript": {
3535
"exportsPresence": "error",
36+
"inlineConst": true,
3637
"typeReexportsPresence": "tolerant",
3738
},
3839
},
@@ -477,6 +478,7 @@ exports[`applyDefaultPlugins > should apply default plugins correctly when produ
477478
"parser": {
478479
"javascript": {
479480
"exportsPresence": "error",
481+
"inlineConst": true,
480482
"typeReexportsPresence": "tolerant",
481483
},
482484
},
@@ -918,6 +920,7 @@ exports[`applyDefaultPlugins > should apply default plugins correctly when targe
918920
"parser": {
919921
"javascript": {
920922
"exportsPresence": "error",
923+
"inlineConst": true,
921924
"typeReexportsPresence": "tolerant",
922925
},
923926
},
@@ -1290,6 +1293,7 @@ exports[`applyDefaultPlugins > should apply default plugins correctly when targe
12901293
"javascript": {
12911294
"dynamicImportMode": "eager",
12921295
"exportsPresence": "error",
1296+
"inlineConst": true,
12931297
"typeReexportsPresence": "tolerant",
12941298
},
12951299
},

packages/core/src/plugins/basic.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export const pluginBasic = (): RsbuildPlugin => ({
7070
// Align with the futureDefaults of webpack 6
7171
chain.module.parser.merge({
7272
javascript: {
73+
inlineConst: true,
7374
exportsPresence: 'error',
7475
typeReexportsPresence: 'tolerant',
7576
},
@@ -97,6 +98,7 @@ export const pluginBasic = (): RsbuildPlugin => ({
9798
...chain.get('experiments'),
9899
lazyBarrel: true,
99100
inlineEnum: true,
101+
inlineConst: true,
100102
typeReexportsPresence: true,
101103
rspackFuture: {
102104
bundlerInfo: {

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ exports[`plugin-basic > should apply basic config correctly in development 1`] =
55
"context": "<ROOT>/packages/core/tests",
66
"devtool": "cheap-module-source-map",
77
"experiments": {
8+
"inlineConst": true,
89
"inlineEnum": true,
910
"lazyBarrel": true,
1011
"rspackFuture": {
@@ -22,6 +23,7 @@ exports[`plugin-basic > should apply basic config correctly in development 1`] =
2223
"parser": {
2324
"javascript": {
2425
"exportsPresence": "error",
26+
"inlineConst": true,
2527
"typeReexportsPresence": "tolerant",
2628
},
2729
},
@@ -53,6 +55,7 @@ exports[`plugin-basic > should apply basic config correctly in production 1`] =
5355
"context": "<ROOT>/packages/core/tests",
5456
"devtool": false,
5557
"experiments": {
58+
"inlineConst": true,
5659
"inlineEnum": true,
5760
"lazyBarrel": true,
5861
"rspackFuture": {
@@ -70,6 +73,7 @@ exports[`plugin-basic > should apply basic config correctly in production 1`] =
7073
"parser": {
7174
"javascript": {
7275
"exportsPresence": "error",
76+
"inlineConst": true,
7377
"typeReexportsPresence": "tolerant",
7478
},
7579
},

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ exports[`should use Rspack as the default bundler > apply Rspack correctly 1`] =
1111
},
1212
"experiments": {
1313
"asyncWebAssembly": true,
14+
"inlineConst": true,
1415
"inlineEnum": true,
1516
"lazyBarrel": true,
1617
"rspackFuture": {
@@ -32,6 +33,7 @@ exports[`should use Rspack as the default bundler > apply Rspack correctly 1`] =
3233
"parser": {
3334
"javascript": {
3435
"exportsPresence": "error",
36+
"inlineConst": true,
3537
"typeReexportsPresence": "tolerant",
3638
},
3739
},

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ exports[`applyDefaultPlugins > should apply default plugins correctly 1`] = `
1111
},
1212
"experiments": {
1313
"asyncWebAssembly": true,
14+
"inlineConst": true,
1415
"inlineEnum": true,
1516
"lazyBarrel": true,
1617
"rspackFuture": {
@@ -32,6 +33,7 @@ exports[`applyDefaultPlugins > should apply default plugins correctly 1`] = `
3233
"parser": {
3334
"javascript": {
3435
"exportsPresence": "error",
36+
"inlineConst": true,
3537
"typeReexportsPresence": "tolerant",
3638
},
3739
},
@@ -525,6 +527,7 @@ exports[`applyDefaultPlugins > should apply default plugins correctly when prod
525527
},
526528
"experiments": {
527529
"asyncWebAssembly": true,
530+
"inlineConst": true,
528531
"inlineEnum": true,
529532
"lazyBarrel": true,
530533
"rspackFuture": {
@@ -546,6 +549,7 @@ exports[`applyDefaultPlugins > should apply default plugins correctly when prod
546549
"parser": {
547550
"javascript": {
548551
"exportsPresence": "error",
552+
"inlineConst": true,
549553
"typeReexportsPresence": "tolerant",
550554
},
551555
},
@@ -1067,6 +1071,7 @@ exports[`applyDefaultPlugins > should apply default plugins correctly when targe
10671071
},
10681072
"experiments": {
10691073
"asyncWebAssembly": true,
1074+
"inlineConst": true,
10701075
"inlineEnum": true,
10711076
"lazyBarrel": true,
10721077
"rspackFuture": {
@@ -1084,6 +1089,7 @@ exports[`applyDefaultPlugins > should apply default plugins correctly when targe
10841089
"parser": {
10851090
"javascript": {
10861091
"exportsPresence": "error",
1092+
"inlineConst": true,
10871093
"typeReexportsPresence": "tolerant",
10881094
},
10891095
},
@@ -1500,6 +1506,7 @@ exports[`tools.rspack > should match snapshot 1`] = `
15001506
},
15011507
"experiments": {
15021508
"asyncWebAssembly": true,
1509+
"inlineConst": true,
15031510
"inlineEnum": true,
15041511
"lazyBarrel": true,
15051512
"rspackFuture": {
@@ -1521,6 +1528,7 @@ exports[`tools.rspack > should match snapshot 1`] = `
15211528
"parser": {
15221529
"javascript": {
15231530
"exportsPresence": "error",
1531+
"inlineConst": true,
15241532
"typeReexportsPresence": "tolerant",
15251533
},
15261534
},

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1352,6 +1352,7 @@ exports[`environment config > tools.rspack / bundlerChain can be configured in e
13521352
"devtool": "eval-source-map",
13531353
"experiments": {
13541354
"asyncWebAssembly": true,
1355+
"inlineConst": true,
13551356
"inlineEnum": true,
13561357
"lazyBarrel": true,
13571358
"rspackFuture": {
@@ -1373,6 +1374,7 @@ exports[`environment config > tools.rspack / bundlerChain can be configured in e
13731374
"parser": {
13741375
"javascript": {
13751376
"exportsPresence": "error",
1377+
"inlineConst": true,
13761378
"typeReexportsPresence": "tolerant",
13771379
},
13781380
},
@@ -1806,6 +1808,7 @@ exports[`environment config > tools.rspack / bundlerChain can be configured in e
18061808
"devtool": "eval",
18071809
"experiments": {
18081810
"asyncWebAssembly": true,
1811+
"inlineConst": true,
18091812
"inlineEnum": true,
18101813
"lazyBarrel": true,
18111814
"rspackFuture": {
@@ -1823,6 +1826,7 @@ exports[`environment config > tools.rspack / bundlerChain can be configured in e
18231826
"parser": {
18241827
"javascript": {
18251828
"exportsPresence": "error",
1829+
"inlineConst": true,
18261830
"typeReexportsPresence": "tolerant",
18271831
},
18281832
},

0 commit comments

Comments
 (0)