From 3e62ca45224983098ddb00be042678795069c1fb Mon Sep 17 00:00:00 2001 From: harpsealjs Date: Tue, 18 Jun 2024 16:11:37 +0800 Subject: [PATCH] fix: panic of module_graph.get_depth (#6846) --- crates/rspack_core/src/module_graph/mod.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/rspack_core/src/module_graph/mod.rs b/crates/rspack_core/src/module_graph/mod.rs index b2ecef81d48..cfa59ff46c4 100644 --- a/crates/rspack_core/src/module_graph/mod.rs +++ b/crates/rspack_core/src/module_graph/mod.rs @@ -558,10 +558,9 @@ impl<'a> ModuleGraph<'a> { } pub fn get_depth(&self, module_id: &ModuleIdentifier) -> Option { - let mgm = self + self .module_graph_module_by_identifier(module_id) - .expect("should have module graph module"); - mgm.depth + .and_then(|mgm| mgm.depth) } pub fn set_depth(&mut self, module_id: ModuleIdentifier, depth: usize) {