From 2524ae035e288ac0c86bd094c61add8396daa369 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Tue, 20 Aug 2024 19:01:31 +0900 Subject: [PATCH] fix: Move tree shaking config to `experimental.turbo` (#69050) ### What? Move `experimental.treeShaking` to `experimental.turbo.treeShaking` in Rust code. ### Why? To disable it, we need to keep config schema and Rust types in sync. ### How? --- crates/next-core/src/next_config.rs | 10 +++++++--- packages/next/src/server/config-shared.ts | 5 +++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/crates/next-core/src/next_config.rs b/crates/next-core/src/next_config.rs index 1ab87a3d46d90..57c466adcce00 100644 --- a/crates/next-core/src/next_config.rs +++ b/crates/next-core/src/next_config.rs @@ -399,6 +399,7 @@ pub struct ExperimentalTurboConfig { pub resolve_alias: Option>, pub resolve_extensions: Option>, pub use_swc_css: Option, + pub tree_shaking: Option, } #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, TraceRawVcs)] @@ -561,8 +562,6 @@ pub struct ExperimentalConfig { /// (doesn't apply to Turbopack). webpack_build_worker: Option, worker_threads: Option, - - tree_shaking: Option, } #[derive(Clone, Debug, PartialEq, Serialize, Deserialize, TraceRawVcs)] @@ -1105,7 +1104,12 @@ impl NextConfig { self: Vc, is_development: bool, ) -> Result> { - let tree_shaking = self.await?.experimental.tree_shaking; + let tree_shaking = self + .await? + .experimental + .turbo + .as_ref() + .and_then(|v| v.tree_shaking); Ok(OptionTreeShaking(match tree_shaking { Some(false) => Some(TreeShakingMode::ReexportsOnly), diff --git a/packages/next/src/server/config-shared.ts b/packages/next/src/server/config-shared.ts index ab1a82e73a26f..e6c845bc7b770 100644 --- a/packages/next/src/server/config-shared.ts +++ b/packages/next/src/server/config-shared.ts @@ -153,6 +153,11 @@ export interface ExperimentalTurboOptions { * A target memory limit for turbo, in bytes. */ memoryLimit?: number + + /** + * Enable tree shaking for the turbopack dev server and build. + */ + treeShaking?: boolean } export interface WebpackConfigContext {