Skip to content

Commit

Permalink
fix: Move tree shaking config to experimental.turbo (#69050)
Browse files Browse the repository at this point in the history
### 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?
  • Loading branch information
kdy1 authored Aug 20, 2024
1 parent a6b2e8b commit 2524ae0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
10 changes: 7 additions & 3 deletions crates/next-core/src/next_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ pub struct ExperimentalTurboConfig {
pub resolve_alias: Option<IndexMap<RcStr, JsonValue>>,
pub resolve_extensions: Option<Vec<RcStr>>,
pub use_swc_css: Option<bool>,
pub tree_shaking: Option<bool>,
}

#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, TraceRawVcs)]
Expand Down Expand Up @@ -561,8 +562,6 @@ pub struct ExperimentalConfig {
/// (doesn't apply to Turbopack).
webpack_build_worker: Option<bool>,
worker_threads: Option<bool>,

tree_shaking: Option<bool>,
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, TraceRawVcs)]
Expand Down Expand Up @@ -1105,7 +1104,12 @@ impl NextConfig {
self: Vc<Self>,
is_development: bool,
) -> Result<Vc<OptionTreeShaking>> {
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),
Expand Down
5 changes: 5 additions & 0 deletions packages/next/src/server/config-shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 2524ae0

Please sign in to comment.