Commit 6b14ed1e authored by Niklas Mischkulnig's avatar Niklas Mischkulnig

try separate contexts

parent a46ce8a2
......@@ -1224,11 +1224,13 @@ 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(rcstr!("ssr"), true))
}
NextRuntime::Edge => this
.app_project
.project()
.edge_chunking_context(process_client_assets),
.edge_chunking_context(rcstr!("ssr"), process_client_assets),
}
.to_resolved()
.await?,
......@@ -1439,9 +1441,11 @@ impl AppEndpoint {
NextRuntime::NodeJs => Vc::upcast(this.app_project.rsc_module_context()),
},
*module_graphs.full,
this.app_project
.project()
.runtime_chunking_context(process_client_assets, runtime),
this.app_project.project().runtime_chunking_context(
rcstr!("rsc"),
process_client_assets,
runtime,
),
)
.await?;
if emit_rsc_manifests {
......@@ -1739,7 +1743,8 @@ impl AppEndpoint {
let app_entry = self.app_endpoint_entry().await?;
let runtime = app_entry.config.await?.runtime.unwrap_or_default();
let chunking_context = project.runtime_chunking_context(process_client_assets, runtime);
let chunking_context =
project.runtime_chunking_context(rcstr!("rsc"), process_client_assets, runtime);
Ok(match runtime {
NextRuntime::Edge => {
......@@ -1971,9 +1976,11 @@ impl Endpoint for AppEndpoint {
.is_development()
{
let node_root = this.app_project.project().node_root().owned().await?;
let rsc_paths = all_server_paths(output.rsc_assets(), node_root.clone())
// TODO what about manifests outside of rsc/ ?
let mut rsc_paths = all_server_paths(output.rsc_assets(), node_root.clone())
.owned()
.await?;
rsc_paths.retain(|p| p.path.starts_with("server/chunks/rsc"));
let ssr_paths = all_server_paths(output.ssr_assets(), node_root)
.owned()
.await?;
......
......@@ -120,7 +120,7 @@ impl InstrumentationEndpoint {
.chain(std::iter::once(module))
.collect();
let edge_chunking_context = this.project.edge_chunking_context(false);
let edge_chunking_context = this.project.edge_chunking_context(rcstr!("rsc"), false);
let edge_files: Vc<OutputAssets> = edge_chunking_context.evaluated_chunk_group_assets(
module.ident(),
ChunkGroup::Entry(evaluatable_assets),
......@@ -135,7 +135,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(rcstr!("rsc"), false);
let userland_module = self.core_modules().await?.userland_module;
let module_graph = this.project.module_graph(*userland_module);
......
......@@ -127,7 +127,7 @@ impl MiddlewareEndpoint {
.chain(std::iter::once(module))
.collect();
let edge_chunking_context = this.project.edge_chunking_context(false);
let edge_chunking_context = this.project.edge_chunking_context(rcstr!("rsc"), false);
let edge_files = edge_chunking_context.evaluated_chunk_group_assets(
module.ident(),
ChunkGroup::Entry(evaluatable_assets),
......@@ -141,7 +141,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(rcstr!("rsc"), false);
let userland_module = self.entry_module().to_resolved().await?;
let module_graph = this.project.module_graph(*userland_module);
......
......@@ -1216,8 +1216,8 @@ impl PageEndpoint {
.node_root()
.await?
.join("server")?,
project.server_chunking_context(true),
project.edge_chunking_context(true),
project.server_chunking_context(rcstr!("ssr"), true),
project.edge_chunking_context(rcstr!("ssr"), true),
this.pages_project.ssr_runtime_entries(),
this.pages_project.edge_ssr_runtime_entries(),
))
......@@ -1234,8 +1234,12 @@ impl PageEndpoint {
.node_root()
.await?
.join("server/data")?,
this.pages_project.project().server_chunking_context(true),
this.pages_project.project().edge_chunking_context(true),
this.pages_project
.project()
.server_chunking_context(rcstr!("ssr"), true),
this.pages_project
.project()
.edge_chunking_context(rcstr!("ssr"), true),
this.pages_project.ssr_data_runtime_entries(),
this.pages_project.edge_ssr_data_runtime_entries(),
))
......@@ -1252,8 +1256,12 @@ impl PageEndpoint {
.node_root()
.await?
.join("server")?,
this.pages_project.project().server_chunking_context(false),
this.pages_project.project().edge_chunking_context(false),
this.pages_project
.project()
.server_chunking_context(rcstr!("ssr"), false),
this.pages_project
.project()
.edge_chunking_context(rcstr!("ssr"), false),
this.pages_project.ssr_runtime_entries(),
this.pages_project.edge_ssr_runtime_entries(),
))
......
......@@ -1035,6 +1035,7 @@ impl Project {
#[turbo_tasks::function]
pub(super) async fn server_chunking_context(
self: Vc<Self>,
chunk_dir_name: RcStr,
client_assets: bool,
) -> Result<Vc<NodeJsChunkingContext>> {
let options = ServerChunkingContextOptions {
......@@ -1042,6 +1043,7 @@ impl Project {
root_path: self.project_root_path().owned().await?,
node_root: self.node_root().owned().await?,
node_root_to_root_path: self.node_root_to_root_path().owned().await?,
chunk_dir_name,
environment: self.server_compile_time_info().environment(),
module_id_strategy: self.module_ids(),
export_usage: self.export_usage(),
......@@ -1064,12 +1066,14 @@ impl Project {
#[turbo_tasks::function]
pub(super) async fn edge_chunking_context(
self: Vc<Self>,
chunk_dir_name: RcStr,
client_assets: bool,
) -> Result<Vc<Box<dyn ChunkingContext>>> {
let options = EdgeChunkingContextOptions {
mode: self.next_mode(),
root_path: self.project_root_path().owned().await?,
node_root: self.node_root().owned().await?,
chunk_dir_name,
output_root_to_root_path: self.node_root_to_root_path(),
environment: self.edge_compile_time_info().environment(),
module_id_strategy: self.module_ids(),
......@@ -1093,12 +1097,15 @@ impl Project {
#[turbo_tasks::function]
pub(super) fn runtime_chunking_context(
self: Vc<Self>,
chunk_dir_name: RcStr,
client_assets: bool,
runtime: NextRuntime,
) -> 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::Edge => self.edge_chunking_context(chunk_dir_name, client_assets),
NextRuntime::NodeJs => {
Vc::upcast(self.server_chunking_context(chunk_dir_name, client_assets))
}
}
}
......
......@@ -208,6 +208,7 @@ pub struct EdgeChunkingContextOptions {
pub mode: Vc<NextMode>,
pub root_path: FileSystemPath,
pub node_root: FileSystemPath,
pub chunk_dir_name: RcStr,
pub output_root_to_root_path: Vc<RcStr>,
pub environment: Vc<Environment>,
pub module_id_strategy: Vc<Box<dyn ModuleIdStrategy>>,
......@@ -228,6 +229,7 @@ pub async fn get_edge_chunking_context_with_client_assets(
mode,
root_path,
node_root,
chunk_dir_name,
output_root_to_root_path,
environment,
module_id_strategy,
......@@ -244,7 +246,7 @@ pub async fn get_edge_chunking_context_with_client_assets(
output_root.clone(),
output_root_to_root_path.owned().await?,
client_root.clone(),
output_root.join("chunks/ssr")?,
output_root.join("chunks/")?.join(&chunk_dir_name)?,
client_root.join("static/media")?,
environment.to_resolved().await?,
next_mode.runtime_type(),
......@@ -297,6 +299,7 @@ pub async fn get_edge_chunking_context(
root_path,
node_root,
output_root_to_root_path,
chunk_dir_name,
environment,
module_id_strategy,
export_usage,
......@@ -312,7 +315,7 @@ pub async fn get_edge_chunking_context(
output_root.clone(),
output_root_to_root_path.owned().await?,
output_root.clone(),
output_root.join("chunks")?,
output_root.join("chunks")?.join(&chunk_dir_name)?,
output_root.join("assets")?,
environment.to_resolved().await?,
next_mode.runtime_type(),
......
......@@ -1031,6 +1031,7 @@ pub struct ServerChunkingContextOptions {
pub mode: Vc<NextMode>,
pub root_path: FileSystemPath,
pub node_root: FileSystemPath,
pub chunk_dir_name: RcStr,
pub node_root_to_root_path: RcStr,
pub environment: Vc<Environment>,
pub module_id_strategy: Vc<Box<dyn ModuleIdStrategy>>,
......@@ -1051,6 +1052,7 @@ pub async fn get_server_chunking_context_with_client_assets(
mode,
root_path,
node_root,
chunk_dir_name,
node_root_to_root_path,
environment,
module_id_strategy,
......@@ -1070,7 +1072,7 @@ pub async fn get_server_chunking_context_with_client_assets(
node_root.clone(),
node_root_to_root_path,
client_root.clone(),
node_root.join("server/chunks/ssr")?,
node_root.join("server/chunks")?.join(&chunk_dir_name)?,
client_root.join("static/media")?,
environment.to_resolved().await?,
next_mode.runtime_type(),
......@@ -1127,6 +1129,7 @@ pub async fn get_server_chunking_context(
mode,
root_path,
node_root,
chunk_dir_name,
node_root_to_root_path,
environment,
module_id_strategy,
......@@ -1145,7 +1148,7 @@ pub async fn get_server_chunking_context(
node_root.clone(),
node_root_to_root_path,
node_root.clone(),
node_root.join("server/chunks")?,
node_root.join("server/chunks")?.join(&chunk_dir_name)?,
node_root.join("server/assets")?,
environment.to_resolved().await?,
next_mode.runtime_type(),
......
......@@ -21,6 +21,7 @@ function deleteFromRequireCache(filePath: string) {
for (const child of mod.children) {
child.parent = null
}
console.log('delete', filePath)
delete require.cache[filePath]
return true
}
......
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