Skip to content

Commit 0b93444

Browse files
committed
fix collect with multi-module entry chunk groups
1 parent 6afc5e6 commit 0b93444

File tree

1 file changed

+13
-8
lines changed
  • turbopack/crates/turbopack-core/src/module_graph

1 file changed

+13
-8
lines changed

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

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,19 @@ pub async fn collect_graph(graph: Vc<ModuleGraph>) -> Result<Vc<CollectedModules
3434

3535
let module_count = graphs.iter().map(|g| g.graph.node_count()).sum::<usize>();
3636

37-
// Notably, this is not g.entries()! We are only interested in ChunkGroupEntry::Entry here
37+
let mut module_entry_membership: FxHashMap<ResolvedVc<Box<dyn Module>>, RoaringBitmapWrapper> =
38+
FxHashMap::with_capacity_and_hasher(module_count, Default::default());
39+
// We are only interested in ChunkGroupEntry::Entry here
40+
for (i, entry) in graphs.iter().flat_map(|g| g.entries.iter()).enumerate() {
41+
if let ChunkGroupEntry::Entry(entries) = entry {
42+
for entry in entries.iter() {
43+
module_entry_membership
44+
.entry(*entry)
45+
.or_default()
46+
.insert(i as u32);
47+
}
48+
}
49+
}
3850
let entries = graphs
3951
.iter()
4052
.flat_map(|g| g.entries.iter())
@@ -46,13 +58,6 @@ pub async fn collect_graph(graph: Vc<ModuleGraph>) -> Result<Vc<CollectedModules
4658
.copied()
4759
.collect::<Vec<_>>();
4860

49-
let mut module_entry_membership: FxHashMap<ResolvedVc<Box<dyn Module>>, RoaringBitmapWrapper> =
50-
entries
51-
.iter()
52-
.enumerate()
53-
.map(|(i, e)| (*e, RoaringBitmapWrapper([i as u32].into())))
54-
.collect();
55-
5661
// First, compute the depth for each module in the graph
5762
let module_depth: FxHashMap<ResolvedVc<Box<dyn Module>>, usize> = {
5863
let mut module_depth =

0 commit comments

Comments
 (0)