Skip to content

Commit

Permalink
Tree shaking only for prod
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Sep 13, 2024
1 parent ca85022 commit c3e788a
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions crates/next-core/src/next_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1123,7 +1123,7 @@ impl NextConfig {
#[turbo_tasks::function]
pub async fn tree_shaking_mode_for_foreign_code(
self: Vc<Self>,
_is_development: bool,
is_development: bool,
) -> Result<Vc<OptionTreeShaking>> {
let tree_shaking = self
.await?
Expand All @@ -1135,17 +1135,27 @@ 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())
}

#[turbo_tasks::function]
pub async fn tree_shaking_mode_for_user_code(
self: Vc<Self>,
_is_development: bool,
is_development: bool,
) -> Result<Vc<OptionTreeShaking>> {
Ok(Vc::cell(Some(TreeShakingMode::ModuleFragments)))
Ok(Vc::cell(Some(if is_development {
TreeShakingMode::ReexportsOnly
} else {
TreeShakingMode::ModuleFragments
})))
}

#[turbo_tasks::function]
Expand Down

0 comments on commit c3e788a

Please sign in to comment.