Commit d530b19e authored by Will Binns-Smith's avatar Will Binns-Smith

Share a single NodeJsChunkingContext Vc across all Node.js server endpoints

Remove the client_assets: bool parameter from server_chunking_context —
all Node.js server endpoints (pages, routes, metadata, instrumentation,
middleware) now share the same NodeJsChunkingContext instance
(get_server_chunking_context_with_client_assets). This produces a single
[turbopack]_runtime.js file instead of two, eliminating the need for the
multicast __turbopack_server_hmr_handlers__ dispatcher.

The process_client_assets flag that controls whether client asset manifests
and browser bundles are emitted remains separate and unchanged.
Co-Authored-By: 's avatarClaude <noreply@anthropic.com>
parent 83b50e61
......@@ -1268,7 +1268,7 @@ impl AppEndpoint {
let ssr_chunking_context = if process_ssr {
Some(
match runtime {
NextRuntime::NodeJs => Vc::upcast(project.server_chunking_context(true)),
NextRuntime::NodeJs => Vc::upcast(project.server_chunking_context()),
NextRuntime::Edge => this
.app_project
.project()
......
......@@ -115,7 +115,7 @@ impl InstrumentationEndpoint {
async fn node_chunk(self: Vc<Self>) -> Result<Vc<Box<dyn OutputAsset>>> {
let this = self.await?;
let chunking_context = this.project.server_chunking_context(false);
let chunking_context = this.project.server_chunking_context();
let userland_module = self.entry_module().to_resolved().await?;
let module_graph = this.project.module_graph(*userland_module);
......
......@@ -126,7 +126,7 @@ impl MiddlewareEndpoint {
async fn node_chunk(self: Vc<Self>) -> Result<Vc<Box<dyn OutputAsset>>> {
let this = self.await?;
let chunking_context = this.project.server_chunking_context(false);
let chunking_context = this.project.server_chunking_context();
let userland_module = self.entry_module().to_resolved().await?;
let module_graph = this.project.module_graph(*userland_module);
......
......@@ -1122,7 +1122,7 @@ impl PageEndpoint {
.node_root()
.await?
.join("server")?,
project.server_chunking_context(true),
project.server_chunking_context(),
project.edge_chunking_context(true),
))
}
......@@ -1138,7 +1138,7 @@ impl PageEndpoint {
.node_root()
.await?
.join("server/data")?,
this.pages_project.project().server_chunking_context(true),
this.pages_project.project().server_chunking_context(),
this.pages_project.project().edge_chunking_context(true),
))
}
......@@ -1154,7 +1154,7 @@ impl PageEndpoint {
.node_root()
.await?
.join("server")?,
this.pages_project.project().server_chunking_context(false),
this.pages_project.project().server_chunking_context(),
this.pages_project.project().edge_chunking_context(false),
))
}
......
......@@ -20,7 +20,7 @@ use next_core::{
},
next_edge::context::EdgeChunkingContextOptions,
next_server::{
ServerChunkingContextOptions, ServerContextType, get_server_chunking_context,
ServerChunkingContextOptions, ServerContextType,
get_server_chunking_context_with_client_assets, get_server_compile_time_info,
get_server_module_options_context, get_server_resolve_options_context,
},
......@@ -1593,7 +1593,6 @@ impl Project {
#[turbo_tasks::function]
pub(super) async fn server_chunking_context(
self: Vc<Self>,
client_assets: bool,
) -> Result<Vc<NodeJsChunkingContext>> {
let css_url_suffix = self.next_config().asset_suffix_path();
let options = ServerChunkingContextOptions {
......@@ -1623,11 +1622,7 @@ impl Project {
css_url_suffix,
hash_salt: self.next_config().output_hash_salt().to_resolved().await?,
};
Ok(if client_assets {
get_server_chunking_context_with_client_assets(options)
} else {
get_server_chunking_context(options)
})
Ok(get_server_chunking_context_with_client_assets(options))
}
#[turbo_tasks::function]
......@@ -1678,7 +1673,7 @@ impl Project {
) -> Vc<Box<dyn ChunkingContext>> {
match runtime {
NextRuntime::Edge => self.edge_chunking_context(client_assets),
NextRuntime::NodeJs => Vc::upcast(self.server_chunking_context(client_assets)),
NextRuntime::NodeJs => Vc::upcast(self.server_chunking_context()),
}
}
......
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