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 {