Skip to content

Commit

Permalink
Add temporary visited_modules.with_incremented_index()
Browse files Browse the repository at this point in the history
  • Loading branch information
wbinnssmith authored and sokra committed Jan 16, 2025
1 parent a960a29 commit 466bf6e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
11 changes: 8 additions & 3 deletions crates/next-api/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -767,11 +767,16 @@ impl AppProject {
graphs.push(graph);
let is_layout =
module.server_path().file_stem().await?.as_deref() == Some("layout");
if is_layout {
visited_modules = if is_layout {
// Only propagate the visited_modules of the parent layout(s), not across
// siblings such as loading.js and page.js.
visited_modules = visited_modules.concatenate(graph);
}
visited_modules.concatenate(graph)
} else {
// Prevents graph index from getting out of sync.
// TODO We should remove VisitedModule entirely in favor of lookups in
// SingleModuleGraph
visited_modules.with_incremented_index()
};
}

let graph =
Expand Down
9 changes: 9 additions & 0 deletions turbopack/crates/turbopack-core/src/module_graph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ impl VisitedModules {
.cell())
}

#[turbo_tasks::function]
pub async fn with_incremented_index(&self) -> Result<Vc<Self>> {
Ok(Self {
modules: self.modules.clone(),
next_graph_idx: self.next_graph_idx + 1,
}
.cell())
}

#[turbo_tasks::function]
pub async fn concatenate(&self, graph: Vc<SingleModuleGraph>) -> Result<Vc<Self>> {
let graph = graph.await?;
Expand Down

0 comments on commit 466bf6e

Please sign in to comment.