From c3e788ada139e7f800173ff8b482f7d63fe0c517 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Thu, 12 Sep 2024 17:34:52 +0900 Subject: [PATCH] Tree shaking only for prod --- crates/next-core/src/next_config.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/crates/next-core/src/next_config.rs b/crates/next-core/src/next_config.rs index 2eba042fa8d9a..1b63a4cf1b95c 100644 --- a/crates/next-core/src/next_config.rs +++ b/crates/next-core/src/next_config.rs @@ -1123,7 +1123,7 @@ impl NextConfig { #[turbo_tasks::function] pub async fn tree_shaking_mode_for_foreign_code( self: Vc, - _is_development: bool, + is_development: bool, ) -> Result> { let tree_shaking = self .await? @@ -1135,7 +1135,13 @@ impl NextConfig { Ok(OptionTreeShaking(match tree_shaking { Some(false) => Some(TreeShakingMode::ReexportsOnly), Some(true) => Some(TreeShakingMode::ModuleFragments), - None => Some(TreeShakingMode::ModuleFragments), + None => { + if is_development { + Some(TreeShakingMode::ReexportsOnly) + } else { + Some(TreeShakingMode::ModuleFragments) + } + } }) .cell()) } @@ -1143,9 +1149,13 @@ impl NextConfig { #[turbo_tasks::function] pub async fn tree_shaking_mode_for_user_code( self: Vc, - _is_development: bool, + is_development: bool, ) -> Result> { - Ok(Vc::cell(Some(TreeShakingMode::ModuleFragments))) + Ok(Vc::cell(Some(if is_development { + TreeShakingMode::ReexportsOnly + } else { + TreeShakingMode::ModuleFragments + }))) } #[turbo_tasks::function]