Skip to content

Commit bca519e

Browse files
sokramischnic
authored andcommitted
Vc stability of ModuleGraph
1 parent 35f93d1 commit bca519e

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

crates/next-api/src/app.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ impl AppProject {
833833
server_component_entries,
834834
} = &*find_server_entries(*rsc_entry).await?;
835835

836-
let graph = SingleModuleGraph::new_with_entries_visited(
836+
let graph = SingleModuleGraph::new_with_entries_visited_intern(
837837
vec![
838838
(
839839
server_utils
@@ -851,7 +851,7 @@ impl AppProject {
851851
let mut visited_modules = VisitedModules::from_graph(graph);
852852

853853
for module in server_component_entries.iter() {
854-
let graph = SingleModuleGraph::new_with_entries_visited(
854+
let graph = SingleModuleGraph::new_with_entries_visited_intern(
855855
vec![(vec![ResolvedVc::upcast(*module)], ChunkGroupType::Entry)],
856856
visited_modules,
857857
);
@@ -872,15 +872,15 @@ impl AppProject {
872872
}
873873
visited_modules
874874
} else {
875-
let graph = SingleModuleGraph::new_with_entries_visited(
875+
let graph = SingleModuleGraph::new_with_entries_visited_intern(
876876
vec![(client_shared_entries, ChunkGroupType::Evaluated)],
877877
VisitedModules::empty(),
878878
);
879879
graphs.push(graph);
880880
VisitedModules::from_graph(graph)
881881
};
882882

883-
let graph = SingleModuleGraph::new_with_entries_visited(
883+
let graph = SingleModuleGraph::new_with_entries_visited_intern(
884884
vec![(vec![ResolvedVc::upcast(rsc_entry)], ChunkGroupType::Entry)],
885885
visited_modules,
886886
);
@@ -889,7 +889,7 @@ impl AppProject {
889889

890890
let base = ModuleGraph::from_graphs(graphs.clone());
891891
let additional_entries = endpoint.additional_entries(base);
892-
let additional_module_graph = SingleModuleGraph::new_with_entries_visited(
892+
let additional_module_graph = SingleModuleGraph::new_with_entries_visited_intern(
893893
additional_entries.owned().await?,
894894
visited_modules,
895895
);

crates/next-api/src/project.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1735,10 +1735,8 @@ async fn whole_app_module_graph_operation(
17351735
let base = ModuleGraph::from_single_graph(base_single_module_graph);
17361736
let additional_entries = project.get_all_additional_entries(base);
17371737

1738-
let additional_module_graph = SingleModuleGraph::new_with_entries_visited(
1739-
additional_entries.owned().await?,
1740-
base_visited_modules,
1741-
);
1738+
let additional_module_graph =
1739+
SingleModuleGraph::new_with_entries_visited(additional_entries, base_visited_modules);
17421740

17431741
let full = ModuleGraph::from_graphs(vec![base_single_module_graph, additional_module_graph]);
17441742
Ok(ModuleGraphs {

turbopack/crates/turbopack-core/src/module_graph/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,6 +1140,14 @@ impl SingleModuleGraph {
11401140

11411141
#[turbo_tasks::function]
11421142
pub async fn new_with_entries_visited(
1143+
entries: Vc<GraphEntries>,
1144+
visited_modules: Vc<VisitedModules>,
1145+
) -> Result<Vc<Self>> {
1146+
SingleModuleGraph::new_inner(&*entries.await?, &visited_modules.await?.modules).await
1147+
}
1148+
1149+
#[turbo_tasks::function]
1150+
pub async fn new_with_entries_visited_intern(
11431151
// This must not be a Vc<Vec<_>> to ensure layout segment optimization hits the cache
11441152
entries: GraphEntriesT,
11451153
visited_modules: Vc<VisitedModules>,

0 commit comments

Comments
 (0)