Skip to content

Commit 34e20ca

Browse files
committed
Turbopack: add debug assertion to check for duplicate modules
1 parent c94753c commit 34e20ca

File tree

1 file changed

+15
-0
lines changed
  • turbopack/crates/turbopack-core/src/module_graph

1 file changed

+15
-0
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,21 @@ impl SingleModuleGraph {
325325

326326
graph.shrink_to_fit();
327327

328+
#[cfg(debug_assertions)]
329+
{
330+
let mut duplicates = Vec::new();
331+
let mut set = FxHashSet::default();
332+
for &module in modules.keys() {
333+
let ident = module.ident().to_string().await?;
334+
if !set.insert(ident.clone()) {
335+
duplicates.push(ident);
336+
}
337+
}
338+
if !duplicates.is_empty() {
339+
panic!("Duplicate module idents in graph: {:#?}", duplicates);
340+
}
341+
}
342+
328343
Ok(SingleModuleGraph {
329344
graph: TracedDiGraph::new(graph),
330345
number_of_modules,

0 commit comments

Comments
 (0)