Skip to content

Commit afeb404

Browse files
authored
refactor(turbopack): Disable tree shaking by default (#73421)
### What? Disable tree shaking by default ### Why? x-ref: https://vercel.slack.com/archives/C03EWR7LGEN/p1733106700499869 ### How?
1 parent d19d26f commit afeb404

File tree

2 files changed

+22
-34
lines changed

2 files changed

+22
-34
lines changed

crates/next-core/src/next_config.rs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,7 +1246,7 @@ impl NextConfig {
12461246
#[turbo_tasks::function]
12471247
pub fn tree_shaking_mode_for_foreign_code(
12481248
&self,
1249-
is_development: bool,
1249+
_is_development: bool,
12501250
) -> Vc<OptionTreeShaking> {
12511251
let tree_shaking = self
12521252
.experimental
@@ -1257,19 +1257,13 @@ impl NextConfig {
12571257
OptionTreeShaking(match tree_shaking {
12581258
Some(false) => Some(TreeShakingMode::ReexportsOnly),
12591259
Some(true) => Some(TreeShakingMode::ModuleFragments),
1260-
None => {
1261-
if is_development {
1262-
Some(TreeShakingMode::ReexportsOnly)
1263-
} else {
1264-
Some(TreeShakingMode::ModuleFragments)
1265-
}
1266-
}
1260+
None => Some(TreeShakingMode::ReexportsOnly),
12671261
})
12681262
.cell()
12691263
}
12701264

12711265
#[turbo_tasks::function]
1272-
pub fn tree_shaking_mode_for_user_code(&self, is_development: bool) -> Vc<OptionTreeShaking> {
1266+
pub fn tree_shaking_mode_for_user_code(&self, _is_development: bool) -> Vc<OptionTreeShaking> {
12731267
let tree_shaking = self
12741268
.experimental
12751269
.turbo
@@ -1279,13 +1273,7 @@ impl NextConfig {
12791273
OptionTreeShaking(match tree_shaking {
12801274
Some(false) => Some(TreeShakingMode::ReexportsOnly),
12811275
Some(true) => Some(TreeShakingMode::ModuleFragments),
1282-
None => {
1283-
if is_development {
1284-
Some(TreeShakingMode::ReexportsOnly)
1285-
} else {
1286-
Some(TreeShakingMode::ModuleFragments)
1287-
}
1288-
}
1276+
None => Some(TreeShakingMode::ReexportsOnly),
12891277
})
12901278
.cell()
12911279
}

test/turbopack-build-tests-manifest.json

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15604,68 +15604,68 @@
1560415604
"runtimeError": false
1560515605
},
1560615606
"test/production/app-dir/actions-tree-shaking/basic/basic.test.ts": {
15607-
"passed": [
15607+
"passed": [],
15608+
"failed": [
1560815609
"actions-tree-shaking - basic should not have the unused action in the manifest"
1560915610
],
15610-
"failed": [],
1561115611
"pending": [],
1561215612
"flakey": [],
1561315613
"runtimeError": false
1561415614
},
1561515615
"test/production/app-dir/actions-tree-shaking/mixed-module-actions/mixed-module-actions-edge.test.ts": {
15616-
"passed": [
15616+
"passed": [],
15617+
"failed": [
1561715618
"actions-tree-shaking - mixed-module-actions should not do tree shake for cjs module when import server actions"
1561815619
],
15619-
"failed": [],
1562015620
"pending": [],
1562115621
"flakey": [],
1562215622
"runtimeError": false
1562315623
},
1562415624
"test/production/app-dir/actions-tree-shaking/mixed-module-actions/mixed-module-actions.test.ts": {
15625-
"passed": [
15625+
"passed": [],
15626+
"failed": [
1562615627
"actions-tree-shaking - mixed-module-actions should not do tree shake for cjs module when import server actions"
1562715628
],
15628-
"failed": [],
1562915629
"pending": [],
1563015630
"flakey": [],
1563115631
"runtimeError": false
1563215632
},
1563315633
"test/production/app-dir/actions-tree-shaking/reexport/reexport-edge.test.ts": {
15634-
"passed": [
15635-
"actions-tree-shaking - reexport should not have the unused action in the manifest"
15636-
],
15634+
"passed": [],
1563715635
"failed": [
15636+
"actions-tree-shaking - reexport should not tree-shake namespace exports the manifest",
15637+
"actions-tree-shaking - reexport should not have the unused action in the manifest",
1563815638
"actions-tree-shaking - reexport should keep all the action exports for namespace export case on client layer"
1563915639
],
1564015640
"pending": [],
1564115641
"flakey": [],
1564215642
"runtimeError": false
1564315643
},
1564415644
"test/production/app-dir/actions-tree-shaking/reexport/reexport.test.ts": {
15645-
"passed": [
15646-
"actions-tree-shaking - reexport should not have the unused action in the manifest"
15647-
],
15645+
"passed": [],
1564815646
"failed": [
15647+
"actions-tree-shaking - reexport should not tree-shake namespace exports the manifest",
15648+
"actions-tree-shaking - reexport should not have the unused action in the manifest",
1564915649
"actions-tree-shaking - reexport should keep all the action exports for namespace export case on client layer"
1565015650
],
1565115651
"pending": [],
1565215652
"flakey": [],
1565315653
"runtimeError": false
1565415654
},
1565515655
"test/production/app-dir/actions-tree-shaking/shared-module-actions/shared-module-actions-edge.test.ts": {
15656-
"passed": [
15656+
"passed": [],
15657+
"failed": [
1565715658
"actions-tree-shaking - shared-module-actions should not have the unused action in the manifest"
1565815659
],
15659-
"failed": [],
1566015660
"pending": [],
1566115661
"flakey": [],
1566215662
"runtimeError": false
1566315663
},
1566415664
"test/production/app-dir/actions-tree-shaking/shared-module-actions/shared-module-actions.test.ts": {
15665-
"passed": [
15665+
"passed": [],
15666+
"failed": [
1566615667
"actions-tree-shaking - shared-module-actions should not have the unused action in the manifest"
1566715668
],
15668-
"failed": [],
1566915669
"pending": [],
1567015670
"flakey": [],
1567115671
"runtimeError": false
@@ -15689,10 +15689,10 @@
1568915689
"runtimeError": false
1569015690
},
1569115691
"test/production/app-dir/actions-tree-shaking/client-actions-tree-shaking/client-actions-tree-shaking.test.ts": {
15692-
"passed": [
15692+
"passed": [],
15693+
"failed": [
1569315694
"app-dir - client-actions-tree-shaking should not bundle unused server reference id in client bundles"
1569415695
],
15695-
"failed": [],
1569615696
"pending": [],
1569715697
"flakey": [],
1569815698
"runtimeError": false

0 commit comments

Comments
 (0)