Unverified Commit 49820961 authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

Turbopack: Don't add client_runtime_entries to Route Handler compilation (#83655)

## What?

Currently Route Handlers trigger a compile for the client-side JS
runtime but it's not required when compiling route handlers.
parent bdb12360
...@@ -1213,13 +1213,21 @@ impl AppEndpoint { ...@@ -1213,13 +1213,21 @@ impl AppEndpoint {
let runtime = app_entry.config.await?.runtime.unwrap_or_default(); let runtime = app_entry.config.await?.runtime.unwrap_or_default();
let rsc_entry = app_entry.rsc_entry; let rsc_entry = app_entry.rsc_entry;
let is_app_page = matches!(this.ty, AppEndpointType::Page { .. });
let module_graphs = this let module_graphs = this
.app_project .app_project
.app_module_graphs( .app_module_graphs(
self, self,
*rsc_entry, *rsc_entry,
this.app_project.client_runtime_entries(), // We only need the client runtime entries for pages not for Route Handlers
matches!(this.ty, AppEndpointType::Page { .. }), if is_app_page {
this.app_project.client_runtime_entries()
} else {
EvaluatableAssets::empty()
},
is_app_page,
) )
.await?; .await?;
...@@ -1241,25 +1249,34 @@ impl AppEndpoint { ...@@ -1241,25 +1249,34 @@ impl AppEndpoint {
None None
}; };
let client_shared_chunk_group = get_app_client_shared_chunk_group( // We only need the client runtime entries for pages not for Route Handlers
AssetIdent::from_path(project.project_path().owned().await?) let (availability_info, client_shared_chunks) = if is_app_page {
.with_modifier(rcstr!("client-shared-chunks")), let client_shared_chunk_group = get_app_client_shared_chunk_group(
this.app_project.client_runtime_entries(), AssetIdent::from_path(project.project_path().owned().await?)
*module_graphs.full, .with_modifier(rcstr!("client-shared-chunks")),
*client_chunking_context, this.app_project.client_runtime_entries(),
) *module_graphs.full,
.await?; *client_chunking_context,
)
.await?;
let mut client_shared_chunks = vec![]; let mut client_shared_chunks = vec![];
for chunk in client_shared_chunk_group.assets.await?.iter().copied() { for chunk in client_shared_chunk_group.assets.await?.iter().copied() {
client_assets.insert(chunk); client_assets.insert(chunk);
let chunk_path = chunk.path().await?; let chunk_path = chunk.path().await?;
if chunk_path.has_extension(".js") { if chunk_path.has_extension(".js") {
client_shared_chunks.push(chunk); client_shared_chunks.push(chunk);
}
} }
}
let client_shared_availability_info = client_shared_chunk_group.availability_info; (
client_shared_chunk_group.availability_info,
client_shared_chunks,
)
} else {
(AvailabilityInfo::Root, vec![])
};
let global_information = get_global_information_for_endpoint( let global_information = get_global_information_for_endpoint(
*module_graphs.base, *module_graphs.base,
...@@ -1282,7 +1299,7 @@ impl AppEndpoint { ...@@ -1282,7 +1299,7 @@ impl AppEndpoint {
*client_references, *client_references,
*module_graphs.full, *module_graphs.full,
*client_chunking_context, *client_chunking_context,
client_shared_availability_info, availability_info,
ssr_chunking_context.map(|ctx| *ctx), ssr_chunking_context.map(|ctx| *ctx),
) )
.to_resolved() .to_resolved()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment