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

try separate contexts

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