@@ -89,7 +89,7 @@ impl ModernModuleLibraryPlugin {
8989 for module_id in & module_ids {
9090 let module = module_graph
9191 . module_by_identifier ( module_id)
92- . expect ( "should have module" ) ;
92+ . expect ( "we have mgm we know for sure we have module" ) ;
9393
9494 if let Some ( module) = module. as_ref ( ) . downcast_ref :: < ConcatenatedModule > ( ) {
9595 concatenated_module_ids. insert ( * module_id) ;
@@ -103,9 +103,9 @@ impl ModernModuleLibraryPlugin {
103103 . iter ( )
104104 . filter ( |id| !concatenated_module_ids. contains ( id) )
105105 . filter ( |id| {
106- let mgm = module_graph
107- . module_graph_module_by_identifier ( id )
108- . expect ( "should have module" ) ;
106+ let Some ( mgm) = module_graph. module_graph_module_by_identifier ( id ) else {
107+ return false ;
108+ } ;
109109 let reasons = & mgm. optimization_bailout ;
110110
111111 let is_concatenation_entry_candidate = reasons
@@ -247,7 +247,9 @@ async fn finish_make(&self, compilation: &mut Compilation) -> Result<()> {
247247 // Remove `import()` runtime.
248248 for module in mg. modules ( ) . values ( ) {
249249 for block_id in module. get_blocks ( ) {
250- let block = mg. block_by_id ( block_id) . expect ( "should have block" ) ;
250+ let Some ( block) = mg. block_by_id ( block_id) else {
251+ continue ;
252+ } ;
251253 for block_dep_id in block. get_dependencies ( ) {
252254 let block_dep = mg. dependency_by_id ( block_dep_id) ;
253255 if let Some ( block_dep) = block_dep {
@@ -257,9 +259,9 @@ async fn finish_make(&self, compilation: &mut Compilation) -> Result<()> {
257259 // Try find the connection with a import dependency pointing to an external module.
258260 // If found, remove the connection and add a new import dependency to performs the external module ID replacement.
259261 let import_module_id = import_dep_connection. module_identifier ( ) ;
260- let import_module = mg
261- . module_by_identifier ( import_module_id )
262- . expect ( "should have mgm" ) ;
262+ let Some ( import_module) = mg. module_by_identifier ( import_module_id ) else {
263+ continue ;
264+ } ;
263265
264266 if let Some ( external_module) = import_module. as_external_module ( ) {
265267 let new_dep = ModernModuleImportDependency :: new (
@@ -283,9 +285,9 @@ async fn finish_make(&self, compilation: &mut Compilation) -> Result<()> {
283285 // Reexport star from external module.
284286 // Only preserve star reexports for module graph entry, nested reexports are not supported.
285287 for dep_id in & compilation. make_artifact . entry_dependencies {
286- let module = mg
287- . get_module_by_dependency_id ( dep_id )
288- . expect ( "should have mgm" ) ;
288+ let Some ( module) = mg. get_module_by_dependency_id ( dep_id ) else {
289+ continue ;
290+ } ;
289291
290292 let mut module_id_to_connections: IdentifierMap < Vec < DependencyId > > = IdentifierMap :: default ( ) ;
291293 mg. get_outgoing_connections ( & module. identifier ( ) )
@@ -306,9 +308,9 @@ async fn finish_make(&self, compilation: &mut Compilation) -> Result<()> {
306308 let reexport_connection = mg. connection_by_dependency_id ( & reexport_dep. id ) ;
307309 if let Some ( reexport_connection) = reexport_connection {
308310 let import_module_id = reexport_connection. module_identifier ( ) ;
309- let import_module = mg
310- . module_by_identifier ( import_module_id )
311- . expect ( "should have mgm" ) ;
311+ let Some ( import_module) = mg. module_by_identifier ( import_module_id ) else {
312+ continue ;
313+ } ;
312314
313315 if let Some ( external_module) = import_module. as_external_module ( ) {
314316 if reexport_dep. request == external_module. user_request ( ) {
0 commit comments