Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions crates/next-api/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1119,6 +1119,9 @@ impl Project {
source_maps: self.next_config().client_source_maps(self.next_mode()),
no_mangling: self.no_mangling(),
scope_hoisting: self.next_config().turbo_scope_hoisting(self.next_mode()),
nested_async_chunking: self
.next_config()
.turbo_nested_async_chunking(self.next_mode(), true),
debug_ids: self.next_config().turbopack_debug_ids(),
should_use_absolute_url_references: self.next_config().inline_css(),
}))
Expand All @@ -1141,6 +1144,9 @@ impl Project {
turbo_source_maps: self.next_config().server_source_maps(),
no_mangling: self.no_mangling(),
scope_hoisting: self.next_config().turbo_scope_hoisting(self.next_mode()),
nested_async_chunking: self
.next_config()
.turbo_nested_async_chunking(self.next_mode(), false),
debug_ids: self.next_config().turbopack_debug_ids(),
client_root: self.client_relative_path().owned().await?,
asset_prefix: self.next_config().computed_asset_prefix().owned().await?,
Expand Down Expand Up @@ -1169,6 +1175,9 @@ impl Project {
turbo_source_maps: self.next_config().server_source_maps(),
no_mangling: self.no_mangling(),
scope_hoisting: self.next_config().turbo_scope_hoisting(self.next_mode()),
nested_async_chunking: self
.next_config()
.turbo_nested_async_chunking(self.next_mode(), false),
client_root: self.client_relative_path().owned().await?,
asset_prefix: self.next_config().computed_asset_prefix().owned().await?,
};
Expand Down
6 changes: 4 additions & 2 deletions crates/next-core/src/next_client/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ pub struct ClientChunkingContextOptions {
pub source_maps: Vc<bool>,
pub no_mangling: Vc<bool>,
pub scope_hoisting: Vc<bool>,
pub nested_async_chunking: Vc<bool>,
pub debug_ids: Vc<bool>,
pub should_use_absolute_url_references: Vc<bool>,
}
Expand All @@ -448,6 +449,7 @@ pub async fn get_client_chunking_context(
source_maps,
no_mangling,
scope_hoisting,
nested_async_chunking,
debug_ids,
should_use_absolute_url_references,
} = options;
Expand Down Expand Up @@ -484,7 +486,8 @@ pub async fn get_client_chunking_context(
.export_usage(*export_usage.await?)
.module_id_strategy(module_id_strategy.to_resolved().await?)
.debug_ids(*debug_ids.await?)
.should_use_absolute_url_references(*should_use_absolute_url_references.await?);
.should_use_absolute_url_references(*should_use_absolute_url_references.await?)
.nested_async_availability(*nested_async_chunking.await?);

if next_mode.is_development() {
builder = builder
Expand All @@ -510,7 +513,6 @@ pub async fn get_client_chunking_context(
},
)
.use_content_hashing(ContentHashing::Direct { length: 16 })
.nested_async_availability(true)
.module_merging(*scope_hoisting.await?);
}

Expand Down
25 changes: 25 additions & 0 deletions crates/next-core/src/next_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,8 @@ pub struct ExperimentalConfig {
turbopack_source_maps: Option<bool>,
turbopack_tree_shaking: Option<bool>,
turbopack_scope_hoisting: Option<bool>,
turbopack_client_side_nested_async_chunking: Option<bool>,
turbopack_server_side_nested_async_chunking: Option<bool>,
turbopack_import_type_bytes: Option<bool>,
turbopack_use_system_tls_certs: Option<bool>,
/// Disable automatic configuration of the sass loader.
Expand Down Expand Up @@ -1790,6 +1792,29 @@ impl NextConfig {
}))
}

#[turbo_tasks::function]
pub async fn turbo_nested_async_chunking(
&self,
mode: Vc<NextMode>,
client_side: bool,
) -> Result<Vc<bool>> {
let option = if client_side {
self.experimental
.turbopack_client_side_nested_async_chunking
} else {
self.experimental
.turbopack_server_side_nested_async_chunking
};
Ok(Vc::cell(if let Some(value) = option {
value
} else {
match *mode.await? {
NextMode::Development => false,
NextMode::Build => client_side,
}
}))
}

#[turbo_tasks::function]
pub async fn turbopack_import_type_bytes(&self) -> Vc<bool> {
Vc::cell(
Expand Down
9 changes: 7 additions & 2 deletions crates/next-core/src/next_edge/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ pub struct EdgeChunkingContextOptions {
pub turbo_source_maps: Vc<bool>,
pub no_mangling: Vc<bool>,
pub scope_hoisting: Vc<bool>,
pub nested_async_chunking: Vc<bool>,
pub client_root: FileSystemPath,
pub asset_prefix: RcStr,
}
Expand All @@ -229,6 +230,7 @@ pub async fn get_edge_chunking_context_with_client_assets(
turbo_source_maps,
no_mangling,
scope_hoisting,
nested_async_chunking,
client_root,
asset_prefix,
} = options;
Expand Down Expand Up @@ -259,7 +261,8 @@ pub async fn get_edge_chunking_context_with_client_assets(
SourceMapsType::None
})
.module_id_strategy(module_id_strategy.to_resolved().await?)
.export_usage(*export_usage.await?);
.export_usage(*export_usage.await?)
.nested_async_availability(*nested_async_chunking.await?);

if !next_mode.is_development() {
builder = builder
Expand Down Expand Up @@ -300,6 +303,7 @@ pub async fn get_edge_chunking_context(
turbo_source_maps,
no_mangling,
scope_hoisting,
nested_async_chunking,
client_root,
asset_prefix,
} = options;
Expand Down Expand Up @@ -336,7 +340,8 @@ pub async fn get_edge_chunking_context(
SourceMapsType::None
})
.module_id_strategy(module_id_strategy.to_resolved().await?)
.export_usage(*export_usage.await?);
.export_usage(*export_usage.await?)
.nested_async_availability(*nested_async_chunking.await?);

if !next_mode.is_development() {
builder = builder
Expand Down
9 changes: 7 additions & 2 deletions crates/next-core/src/next_server/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,7 @@ pub struct ServerChunkingContextOptions {
pub turbo_source_maps: Vc<bool>,
pub no_mangling: Vc<bool>,
pub scope_hoisting: Vc<bool>,
pub nested_async_chunking: Vc<bool>,
pub debug_ids: Vc<bool>,
pub client_root: FileSystemPath,
pub asset_prefix: RcStr,
Expand All @@ -1022,6 +1023,7 @@ pub async fn get_server_chunking_context_with_client_assets(
turbo_source_maps,
no_mangling,
scope_hoisting,
nested_async_chunking,
debug_ids,
client_root,
asset_prefix,
Expand Down Expand Up @@ -1058,7 +1060,8 @@ pub async fn get_server_chunking_context_with_client_assets(
.module_id_strategy(module_id_strategy.to_resolved().await?)
.export_usage(*export_usage.await?)
.file_tracing(next_mode.is_production())
.debug_ids(*debug_ids.await?);
.debug_ids(*debug_ids.await?)
.nested_async_availability(*nested_async_chunking.await?);

builder = builder.source_map_source_type(if next_mode.is_development() {
SourceMapSourceType::AbsoluteFileUri
Expand Down Expand Up @@ -1106,6 +1109,7 @@ pub async fn get_server_chunking_context(
turbo_source_maps,
no_mangling,
scope_hoisting,
nested_async_chunking,
debug_ids,
client_root,
asset_prefix,
Expand Down Expand Up @@ -1142,7 +1146,8 @@ pub async fn get_server_chunking_context(
.module_id_strategy(module_id_strategy.to_resolved().await?)
.export_usage(*export_usage.await?)
.file_tracing(next_mode.is_production())
.debug_ids(*debug_ids.await?);
.debug_ids(*debug_ids.await?)
.nested_async_availability(*nested_async_chunking.await?);

if next_mode.is_development() {
builder = builder.source_map_source_type(SourceMapSourceType::AbsoluteFileUri);
Expand Down
2 changes: 2 additions & 0 deletions packages/next/src/server/config-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,8 @@ export const experimentalSchema = {
turbopackTreeShaking: z.boolean().optional(),
turbopackRemoveUnusedExports: z.boolean().optional(),
turbopackScopeHoisting: z.boolean().optional(),
turbopackClientSideNestedAsyncChunking: z.boolean().optional(),
turbopackServerSideNestedAsyncChunking: z.boolean().optional(),
turbopackImportTypeBytes: z.boolean().optional(),
turbopackUseSystemTlsCerts: z.boolean().optional(),
turbopackUseBuiltinBabel: z.boolean().optional(),
Expand Down
12 changes: 12 additions & 0 deletions packages/next/src/server/config-shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,18 @@ export interface ExperimentalConfig {
*/
turbopackScopeHoisting?: boolean

/**
* Enable nested async chunking for client side assets. Defaults to true in build mode and false in dev mode.
* This optimization computes all possible paths through dynamic imports in the applications to figure out the modules needed at dynamic imports for every path.
*/
turbopackClientSideNestedAsyncChunking?: boolean

/**
* Enable nested async chunking for server side assets. Defaults to false in dev and build mode.
* This optimization computes all possible paths through dynamic imports in the applications to figure out the modules needed at dynamic imports for every path.
*/
turbopackServerSideNestedAsyncChunking?: boolean

/**
* Enable filesystem cache for the turbopack dev server.
*/
Expand Down
Loading