@@ -529,16 +529,14 @@ impl SourceMapProcessor {
529529            bundle_source_url,  sourcemap_url
530530        ) ; 
531531
532-         let  sourcemap_content = match  self . sources . get ( & sourcemap_url)  { 
533-             Some ( source)  => & source. contents , 
534-             None  => { 
535-                 warn ! ( 
536-                     "Cannot find the sourcemap for the RAM bundle using the URL: {}, skipping" , 
537-                     sourcemap_url
538-                 ) ; 
539-                 return  Ok ( ( ) ) ; 
540-             } 
532+         let  Some ( sourcemap_source)  = self . sources . get ( & sourcemap_url)  else  { 
533+             warn ! ( 
534+                 "Cannot find the sourcemap for the RAM bundle using the URL: {}, skipping" , 
535+                 sourcemap_url
536+             ) ; 
537+             return  Ok ( ( ) ) ; 
541538        } ; 
539+         let  sourcemap_content = & sourcemap_source. contents ; 
542540
543541        let  sourcemap_index = match  sourcemap:: decode_slice ( sourcemap_content) ? { 
544542            sourcemap:: DecodedMap :: Index ( sourcemap_index)  => sourcemap_index, 
@@ -548,8 +546,28 @@ impl SourceMapProcessor {
548546            } 
549547        } ; 
550548
551-         // We don't need the RAM bundle sourcemap itself 
552-         self . sources . remove ( & sourcemap_url) ; 
549+         // We have to include the bundle sourcemap which is the first section 
550+         // in the bundle source map before the modules maps 
551+         if  let  Some ( index_section)  = & sourcemap_index
552+             . sections ( ) 
553+             . nth ( 0 ) 
554+             . and_then ( |index_section| index_section. get_sourcemap ( ) ) 
555+         { 
556+             let  mut  index_sourcemap_content:  Vec < u8 >  = vec ! [ ] ; 
557+             index_section. to_writer ( & mut  index_sourcemap_content) ?; 
558+             self . sources . insert ( 
559+                 sourcemap_url. clone ( ) , 
560+                 SourceFile  { 
561+                     url :  sourcemap_source. url . clone ( ) , 
562+                     path :  sourcemap_source. path . clone ( ) , 
563+                     contents :  index_sourcemap_content, 
564+                     ty :  SourceFileType :: SourceMap , 
565+                     headers :  sourcemap_source. headers . clone ( ) , 
566+                     messages :  sourcemap_source. messages . clone ( ) , 
567+                     already_uploaded :  false , 
568+                 } , 
569+             ) ; 
570+         } 
553571
554572        let  ram_bundle_iter =
555573            sourcemap:: ram_bundle:: split_ram_bundle ( ram_bundle,  & sourcemap_index) . unwrap ( ) ; 
0 commit comments