Skip to content

Commit

Permalink
Fix pages router
Browse files Browse the repository at this point in the history
  • Loading branch information
mischnic committed Dec 10, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 62e1bc4 commit 155b5ed
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions crates/next-api/src/module_graph.rs
Original file line number Diff line number Diff line change
@@ -423,21 +423,26 @@ async fn get_module_graph_for_endpoint(
server_component_entries,
} = &*find_server_entries(*entry).await?;

let graph = SingleModuleGraph::new_with_entries_visited(
*entry,
server_utils.iter().map(|m| **m).collect(),
Vc::cell(Default::default()),
)
.to_resolved()
.await?;
let mut visited_modules: HashSet<_> = graph
.await?
.graph
.node_weights()
.map(|n| n.module)
.collect();

let mut graphs = vec![graph];
let mut graphs = vec![];

let mut visited_modules = if !server_utils.is_empty() {
let graph = SingleModuleGraph::new_with_entries_visited(
*entry,
server_utils.iter().map(|m| **m).collect(),
Vc::cell(Default::default()),
)
.to_resolved()
.await?;
graph
.await?
.iter_nodes()
.map(|n| n.module)
.collect::<HashSet<_>>()
} else {
HashSet::new()
};

// ast-grep-ignore: to-resolved-in-loop
for module in server_component_entries
.iter()
.map(|m| ResolvedVc::upcast::<Box<dyn Module>>(*m))
@@ -449,9 +454,12 @@ async fn get_module_graph_for_endpoint(
)
.to_resolved()
.await?;
visited_modules.extend(graph.await?.graph.node_weights().map(|n| n.module));
visited_modules.extend(graph.await?.iter_nodes().map(|n| n.module));
graphs.push(graph);
}

// The previous iterations above (might) have added the entry node, but not actually visited it.
visited_modules.remove(&entry);
let graph = SingleModuleGraph::new_with_entries_visited(
*entry,
vec![*entry],

0 comments on commit 155b5ed

Please sign in to comment.