Skip to content

Commit 6b35981

Browse files
authored
Turbopack: Vc stability of ModuleGraph (#77052)
<!-- Thanks for opening a PR! Your contribution is much appreciated. To make sure your PR is handled as smoothly as possible we request that you follow the checklist sections below. Choose the right checklist for the change(s) that you're making: ## For Contributors ### Improving Documentation - Run `pnpm prettier-fix` to fix formatting issues before opening the PR. - Read the Docs Contribution Guide to ensure your contribution follows the docs guidelines: https://nextjs.org/docs/community/contribution-guide ### Adding or Updating Examples - The "examples guidelines" are followed from our contributing doc https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md - Make sure the linting passes by running `pnpm build && pnpm lint`. See https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md ### Fixing a bug - Related issues linked using `fixes #number` - Tests added. See: https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ### Adding a feature - Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. (A discussion must be opened, see https://github.com/vercel/next.js/discussions/new?category=ideas) - Related issues/discussions are linked using `fixes #number` - e2e tests added (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) - Documentation added - Telemetry added. In case of a feature if it's used or not. - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ## For Maintainers - Minimal description (aim for explaining to someone not on the team to understand the PR) - When linking to a Slack thread, you might want to share details of the conclusion - Link both the Linear (Fixes NEXT-xxx) and the GitHub issues - Add review comments if necessary to explain to the reviewer the logic behind a change ### What? ### Why? ### How? Closes NEXT- Fixes # -->
1 parent 35f93d1 commit 6b35981

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)