Skip to content

Commit

Permalink
Address review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
mischnic committed Dec 11, 2024
1 parent 4ac276c commit 3960bda
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions crates/next-api/src/module_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,24 +292,23 @@ impl SingleModuleGraph {
}
}

let root_idx = match root {
Some(root) => {
if !modules.contains_key(&root) {
let root_idx = graph.add_node(SingleModuleGraphNode {
module: root,
issues: Default::default(),
layer: None,
// ident: root.ident().to_string().await?,
});
for entry in entries {
graph.add_edge(root_idx, *modules.get(entry).unwrap(), ());
}
Some((root, root_idx))
} else {
None
let root_idx = if let Some(root) = root {
if !modules.contains_key(&root) {
let root_idx = graph.add_node(SingleModuleGraphNode {
module: root,
issues: Default::default(),
layer: None,
// ident: root.ident().to_string().await?,
});
for entry in entries {
graph.add_edge(root_idx, *modules.get(entry).unwrap(), ());
}
Some((root, root_idx))
} else {
None
}
None => None,
} else {
None
};

Ok(SingleModuleGraph {
Expand Down Expand Up @@ -397,12 +396,14 @@ impl SingleModuleGraph {
Ok(())
}

/// Traverses all reachable edges in reverse topological order (from leaves to the entry), the
/// preorder visitor can be used to forward state down the graph, and to skip subgraphs
/// Traverses all reachable edges in topological order. The preorder visitor can be used to
/// forward state down the graph, and to skip subgraphs
///
/// Use this to collect modules in evaluation order.
///
/// Target nodes can be revisited (once per incoming edge).
/// Edges are traversed in normal order, so should correspond to reference order.
pub fn traverse_edges_from_entry_reverse_topological<'a, S>(
pub fn traverse_edges_from_entry_topological<'a, S>(
&'a self,
entry: ResolvedVc<Box<dyn Module>>,
state: &mut S,
Expand Down Expand Up @@ -756,7 +757,7 @@ impl ClientReferencesGraph {
let mut client_references_by_server_component =
FxIndexMap::from_iter([(None, Vec::new())]);

graph.traverse_edges_from_entry_reverse_topological(
graph.traverse_edges_from_entry_topological(
entry,
// state_map is `module -> Option< the current so parent server component >`
&mut HashMap::new(),
Expand Down

0 comments on commit 3960bda

Please sign in to comment.