Skip to content

Commit

Permalink
Use graph.traverse_from_entry
Browse files Browse the repository at this point in the history
  • Loading branch information
mischnic committed Nov 28, 2024
1 parent 0288191 commit ba6e7ef
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions crates/next-api/src/module_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,19 +293,14 @@ impl ServerActionsGraph {
Cow::Borrowed(data)
} else {
// The graph contains the whole app, traverse and collect all reachable imports.
let SingleModuleGraph { graph, entries } = &*self.graph.await?;
let graph = &*self.graph.await?;

let mut result = HashMap::new();

let entry_node = *entries.get(&entry).unwrap();
let mut dfs = Dfs::new(&graph, entry_node);
while let Some(nx) = dfs.next(&graph) {
let weight = *graph.node_weight(nx).unwrap();
if let Some(node_data) = data.get(&weight) {
result.insert(weight, *node_data);
graph.traverse_from_entry(entry, |module| {
if let Some(node_data) = data.get(&module) {
result.insert(module, *node_data);
}
}

})?;
Cow::Owned(result)
};

Expand Down

0 comments on commit ba6e7ef

Please sign in to comment.