Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mischnic committed Dec 10, 2024
1 parent 284e4e4 commit 65d716f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 25 deletions.
18 changes: 2 additions & 16 deletions crates/next-api/src/module_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,20 +450,6 @@ async fn get_module_graph_for_endpoint(
Ok(Vc::cell(graphs))
}

#[turbo_tasks::function]
async fn get_module_graph_for_app_without_issues(
entries: Vc<Modules>,
) -> Result<Vc<SingleModuleGraph>> {
let vc = SingleModuleGraph::new_with_entries(entries);
let graph = vc.resolve_strongly_consistent().await?;
let _issues = vc.take_collectibles::<Box<dyn Issue>>();
// println!(
// "taking {:?}",
// _issues.iter().map(|i| i.dbg()).try_join().await?
// );
Ok(graph)
}

#[turbo_tasks::value]
pub struct NextDynamicGraph {
is_single_page: bool,
Expand Down Expand Up @@ -547,7 +533,7 @@ impl NextDynamicGraph {
}
}

/// The consumers of this shoudln't need to care about the exact contents since it's abstracted away
/// The consumers of this shouldn't need to care about the exact contents since it's abstracted away
/// by the accessor functions, but
/// - In dev, contains information about the modules of the current endpoint only
/// - In prod, there is a single `ReducedGraphs` for the whole app, containing all pages
Expand Down Expand Up @@ -613,7 +599,7 @@ async fn get_reduced_graphs_for_endpoint_inner(
false,
vec![
async move {
get_module_graph_for_app_without_issues(project.get_all_entries())
SingleModuleGraph::new_with_entries(project.get_all_entries())
.to_resolved()
.await
}
Expand Down
15 changes: 9 additions & 6 deletions crates/next-api/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ use crate::{
instrumentation::InstrumentationEndpoint,
middleware::MiddlewareEndpoint,
pages::PagesProject,
route::{Endpoint, Route},
route::{AppPageRoute, Endpoint, Route},
versioned_content_map::{OutputAssetsOperation, VersionedContentMap},
};

Expand Down Expand Up @@ -703,18 +703,21 @@ impl Project {
match route {
Route::Page {
html_endpoint,
data_endpoint,
data_endpoint: _,
} => {
add_endpoint(**html_endpoint, &mut modules).await?;
add_endpoint(**data_endpoint, &mut modules).await?;
}
Route::PageApi { endpoint } => {
add_endpoint(**endpoint, &mut modules).await?;
}
Route::AppPage(page_routes) => {
for page_route in page_routes {
add_endpoint(page_route.html_endpoint, &mut modules).await?;
add_endpoint(page_route.rsc_endpoint, &mut modules).await?;
for AppPageRoute {
original_name: _,
html_endpoint,
rsc_endpoint: _,
} in page_routes
{
add_endpoint(*html_endpoint, &mut modules).await?;
}
}
Route::AppRoute {
Expand Down
5 changes: 2 additions & 3 deletions turbopack/crates/turbo-tasks/src/graph/adjacency_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ where
}
}

/// Returns an owned iterator over the nodes in reverse topological order,
/// Returns an owned iterator over all edges (node pairs) in breadth first order,
/// starting from the roots.
pub fn into_breadth_first_edges(self) -> IntoBreadthFirstEdges<T> {
IntoBreadthFirstEdges {
Expand Down Expand Up @@ -212,15 +212,14 @@ where
return Some((parent, current));
};

if !self.visited.contains(&current) {
if self.visited.insert(current.clone()) {
self.stack.extend(
neighbors
.iter()
.rev()
.map(|neighbor| (Some(current.clone()), neighbor.clone())),
);
}
self.visited.insert(current.clone());

Some((parent, current))
}
Expand Down

0 comments on commit 65d716f

Please sign in to comment.