@@ -70,6 +70,13 @@ impl<'a> Bundle<'a> {
7070
7171 for stmt_info in module. stmt_infos . iter ( ) . chain ( linking_info. facade_stmt_infos . iter ( ) ) {
7272 for declared in & stmt_info. declared_symbols {
73+ // TODO: pass debug_assert!(self.graph.symbols.get(*declared).chunk_id.is_none());
74+ // FIXME: I don't think this is correct, even though the assigned chunk_id is the same as the current chunk_id.
75+ // A declared symbol should only be processed once.
76+ debug_assert ! (
77+ self . graph. symbols. get( * declared) . chunk_id. unwrap_or( chunk_id) == chunk_id
78+ ) ;
79+
7380 self . graph . symbols . get_mut ( * declared) . chunk_id = Some ( chunk_id) ;
7481 }
7582
@@ -98,11 +105,13 @@ impl<'a> Bundle<'a> {
98105 }
99106 }
100107 }
101-
102108 for ( chunk_id, chunk) in chunk_graph. chunks . iter_mut_enumerated ( ) {
103109 let chunk_meta_imports = & chunk_meta_imports_vec[ chunk_id] ;
104110 for import_ref in chunk_meta_imports. iter ( ) . copied ( ) {
105- let importee_chunk_id = self . graph . symbols . get ( import_ref) . chunk_id . unwrap ( ) ;
111+ let import_symbol = self . graph . symbols . get ( import_ref) ;
112+ let importee_chunk_id = import_symbol. chunk_id . unwrap_or_else ( || {
113+ panic ! ( "symbol {import_ref:?} {import_symbol:?} is not assigned to any chunk" )
114+ } ) ;
106115 if chunk_id != importee_chunk_id {
107116 chunk
108117 . imports_from_other_chunks
@@ -168,6 +177,14 @@ impl<'a> Bundle<'a> {
168177 FxHashMap :: with_capacity_and_hasher ( self . graph . entries . len ( ) , BuildHasherDefault :: default ( ) ) ;
169178 let mut chunks = ChunksVec :: with_capacity ( self . graph . entries . len ( ) ) ;
170179
180+ // FIXME: should only do this while `ROLLDOWN_TEST=1`
181+ let _runtime_chunk_id = chunks. push ( Chunk :: new (
182+ Some ( "_rolldown_runtime" . to_string ( ) ) ,
183+ None ,
184+ BitSet :: new ( 0 ) ,
185+ vec ! [ self . graph. runtime. id] ,
186+ ) ) ;
187+
171188 // Create chunk for each static and dynamic entry
172189 for ( entry_index, ( name, module_id) ) in self . graph . entries . iter ( ) . enumerate ( ) {
173190 let count: u32 = u32:: try_from ( entry_index) . unwrap ( ) ;
0 commit comments