Commit 67b17f17 authored by Luke Sandberg's avatar Luke Sandberg

Fix handling of self cycles

eliminate some clones
parent f6685556
...@@ -1939,10 +1939,10 @@ impl Endpoint for AppEndpoint { ...@@ -1939,10 +1939,10 @@ impl Endpoint for AppEndpoint {
}; };
async move { async move {
let output = self.output().await?; let output = self.output();
let output_assets = self.output().output_assets(); let output_assets = output.output_assets();
let node_root = this.app_project.project().node_root(); let output = output.await?;
let node_root_ref = &node_root.await?; let node_root = &*this.app_project.project().node_root().await?;
let (server_paths, client_paths) = if this let (server_paths, client_paths) = if this
.app_project .app_project
...@@ -1951,8 +1951,9 @@ impl Endpoint for AppEndpoint { ...@@ -1951,8 +1951,9 @@ impl Endpoint for AppEndpoint {
.await? .await?
.is_development() .is_development()
{ {
let node_root = this.app_project.project().node_root().await?.clone_value(); let server_paths = all_server_paths(output_assets, node_root.clone())
let server_paths = all_server_paths(output_assets, node_root).owned().await?; .owned()
.await?;
let client_relative_root = this let client_relative_root = this
.app_project .app_project
...@@ -1971,7 +1972,7 @@ impl Endpoint for AppEndpoint { ...@@ -1971,7 +1972,7 @@ impl Endpoint for AppEndpoint {
let written_endpoint = match *output { let written_endpoint = match *output {
AppEndpointOutput::NodeJs { rsc_chunk, .. } => EndpointOutputPaths::NodeJs { AppEndpointOutput::NodeJs { rsc_chunk, .. } => EndpointOutputPaths::NodeJs {
server_entry_path: node_root_ref server_entry_path: node_root
.get_path_to(&*rsc_chunk.path().await?) .get_path_to(&*rsc_chunk.path().await?)
.context("Node.js chunk entry path must be inside the node root")? .context("Node.js chunk entry path must be inside the node root")?
.to_string(), .to_string(),
......
...@@ -15,7 +15,8 @@ use turbopack::css::chunk::CssChunkPlaceable; ...@@ -15,7 +15,8 @@ use turbopack::css::chunk::CssChunkPlaceable;
use turbopack_core::{ use turbopack_core::{
module::Module, module::Module,
module_graph::{ module_graph::{
GraphTraversalAction, SingleModuleGraph, chunk_group_info::RoaringBitmapWrapper, GraphTraversalAction, SingleModuleGraph, SingleModuleGraphModuleNode,
chunk_group_info::RoaringBitmapWrapper,
}, },
}; };
...@@ -56,7 +57,7 @@ impl ClientReferencesSet { ...@@ -56,7 +57,7 @@ impl ClientReferencesSet {
let bitmap = &self let bitmap = &self
.server_components_for_client_references .server_components_for_client_references
.get(&module) .get(&module)
.expect("the passed module should be a client reference module") .expect("Module should be a client reference module")
.0; .0;
bitmap bitmap
...@@ -139,20 +140,26 @@ pub async fn map_client_references( ...@@ -139,20 +140,26 @@ pub async fn map_client_references(
true true
} }
}; };
if let Some((parent_module, _)) = parent_info { if let Some((SingleModuleGraphModuleNode{module: parent_module}, _)) = parent_info
// Skip self cycles such as in
// test/e2e/app-dir/dynamic-import/app/page.tsx where a very-dynamic import induces a
// self cycle. They don't introduce new bits anyway.
&& module != *parent_module
{
// copy parent bits down. visit_preorder always visits parents before // copy parent bits down. visit_preorder always visits parents before
// children so we can assert that the parent it set. // children so we can assert that the parent it set.
let [Some(current), Some(parent)] = let [Some(current), Some(parent)] =
parent_modules.get_disjoint_mut([&module, &parent_module.module]) parent_modules.get_disjoint_mut([&module, parent_module])
else { else {
unreachable!() unreachable!()
}; };
// inherit the server components from the newly observed parent. // inherit the server components from the newly observed parent.
// check if we are adding new bits and thus need to revisit children // check if we are adding new bits and thus need to revisit children unless we are already planning to because this is a new node.
if !should_visit_children { if !should_visit_children {
let len = current.len(); let len = current.len();
*current |= &*parent; *current |= &*parent;
should_visit_children |= len != current.len(); // did we find new bits // did we find new bits? If so visit the children again
should_visit_children |= len != current.len();
} else { } else {
*current |= &*parent; *current |= &*parent;
} }
......
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