11use futures:: Future ;
22use indexmap:: IndexMap ;
3- use rspack_collections:: { IdentifierIndexMap , IdentifierIndexSet , IdentifierMap } ;
3+ use rspack_collections:: { IdentifierIndexMap , IdentifierMap } ;
44use rspack_error:: Result ;
55use rspack_util:: tracing_preset:: TRACING_BENCH_TARGET ;
66use rustc_hash:: FxHashMap as HashMap ;
@@ -9,10 +9,7 @@ use tracing::instrument;
99use crate :: {
1010 ChunkByUkey , ChunkGraph , ChunkGroupByUkey , ChunkGroupUkey , ChunkUkey , Compilation , Logger ,
1111 ModuleIdentifier ,
12- build_chunk_graph:: {
13- code_splitter:: { CodeSplitter , DependenciesBlockIdentifier } ,
14- new_code_splitter:: CodeSplitter as NewCodeSplitter ,
15- } ,
12+ build_chunk_graph:: code_splitter:: { CodeSplitter , DependenciesBlockIdentifier } ,
1613 incremental:: { IncrementalPasses , Mutation } ,
1714} ;
1815
@@ -26,7 +23,6 @@ pub struct CodeSplittingCache {
2623 named_chunk_groups : HashMap < String , ChunkGroupUkey > ,
2724 named_chunks : HashMap < String , ChunkUkey > ,
2825 pub ( crate ) code_splitter : CodeSplitter ,
29- pub ( crate ) new_code_splitter : NewCodeSplitter ,
3026 pub ( crate ) module_idx : IdentifierMap < ( u32 , u32 ) > ,
3127}
3228
@@ -36,11 +32,7 @@ impl CodeSplittingCache {
3632 // we don't need to check if module has changed its incomings
3733 // if it changes, the incoming module changes its outgoings as well
3834 fn can_skip_rebuilding ( & self , this_compilation : & Compilation ) -> bool {
39- if this_compilation. options . experiments . parallel_code_splitting {
40- self . can_skip_rebuilding_new ( this_compilation)
41- } else {
42- self . can_skip_rebuilding_legacy ( this_compilation)
43- }
35+ self . can_skip_rebuilding_legacy ( this_compilation)
4436 }
4537
4638 fn can_skip_rebuilding_legacy ( & self , this_compilation : & Compilation ) -> bool {
@@ -169,123 +161,6 @@ impl CodeSplittingCache {
169161
170162 true
171163 }
172-
173- fn can_skip_rebuilding_new ( & self , this_compilation : & Compilation ) -> bool {
174- let logger = this_compilation. get_logger ( "rspack.Compilation.codeSplittingCache" ) ;
175-
176- if !this_compilation. entries . keys ( ) . eq (
177- this_compilation
178- . build_chunk_graph_artifact
179- . code_splitting_cache
180- . entrypoints
181- . keys ( ) ,
182- ) {
183- logger. log ( "entrypoints change detected, rebuilding chunk graph" ) ;
184- return false ;
185- }
186-
187- if this_compilation
188- . options
189- . optimization
190- . used_exports
191- . is_enable ( )
192- {
193- logger. log ( "used_exports enabled, rebuilding chunk graph for safety" ) ;
194- return false ;
195- }
196-
197- if self . new_code_splitter . module_deps . is_empty ( ) {
198- logger. log ( "no cache detected, rebuilding chunk graph" ) ;
199- return false ;
200- }
201-
202- let Some ( mutations) = this_compilation
203- . incremental
204- . mutations_read ( IncrementalPasses :: MAKE )
205- else {
206- logger. log ( "incremental for make disabled, rebuilding chunk graph" ) ;
207- // if disable incremental for make phase, we can't skip rebuilding
208- return false ;
209- } ;
210-
211- // if we have module removal, we can't skip rebuilding
212- if mutations
213- . iter ( )
214- . any ( |mutation| matches ! ( mutation, Mutation :: ModuleRemove { .. } ) )
215- {
216- logger. log ( "module removal detected, rebuilding chunk graph" ) ;
217- return false ;
218- }
219-
220- let module_graph = this_compilation. get_module_graph ( ) ;
221- let module_graph_cache = & this_compilation. module_graph_cache_artifact ;
222- let affected_modules = mutations. get_affected_modules_with_module_graph ( & module_graph) ;
223-
224- for module in affected_modules. clone ( ) {
225- let mut current_outgoings_map = IdentifierIndexMap :: < Vec < _ > > :: default ( ) ;
226- let curr_module = module_graph
227- . module_graph_module_by_identifier ( & module)
228- . expect ( "module should exist" ) ;
229-
230- curr_module
231- . all_dependencies
232- . iter ( )
233- . filter ( |dep_id| {
234- module_graph
235- . dependency_by_id ( dep_id)
236- . expect ( "should have dep" )
237- . as_module_dependency ( )
238- . is_none_or ( |module_dep| !module_dep. weak ( ) )
239- } )
240- . filter_map ( |dep| module_graph. connection_by_dependency_id ( dep) )
241- . map ( |conn| ( conn. module_identifier ( ) , conn) )
242- . for_each ( |( module, conn) | current_outgoings_map. entry ( * module) . or_default ( ) . push ( conn) ) ;
243- let mut current_outgoings = IdentifierIndexSet :: default ( ) ;
244-
245- ' outer: for ( m, conns) in current_outgoings_map. iter ( ) {
246- for conn in conns {
247- let conn_state = conn. active_state ( & module_graph, None , module_graph_cache) ;
248- if conn_state. is_not_false ( ) {
249- current_outgoings. insert ( * m) ;
250- continue ' outer;
251- }
252- }
253- }
254-
255- let mut previous_outgoings = IdentifierIndexSet :: default ( ) ;
256- let mut newly_added_module = true ;
257- for module_map in self . new_code_splitter . module_deps . values ( ) {
258- if let Some ( outgoings) = module_map. get ( & module) {
259- newly_added_module = false ;
260- let ( outgoings, _blocks) = outgoings. as_ref ( ) ;
261- for out in outgoings {
262- previous_outgoings. insert ( * out) ;
263- }
264- }
265- }
266-
267- if newly_added_module {
268- logger. log ( format ! ( "new module: {module}" ) ) ;
269- return false ;
270- }
271-
272- if previous_outgoings. len ( ) != current_outgoings. len ( ) {
273- logger. log ( format ! (
274- "module outgoings change detected (outgoings length change): {module}"
275- ) ) ;
276- return false ;
277- }
278-
279- for ( prev, curr) in previous_outgoings. into_iter ( ) . zip ( current_outgoings) {
280- if prev != curr {
281- logger. log ( format ! ( "module outgoings change detected {module}" ) ) ;
282- return false ;
283- }
284- }
285- }
286-
287- true
288- }
289164}
290165
291166#[ instrument( name = "Compilation:code_splitting" , target=TRACING_BENCH_TARGET , skip_all) ]
@@ -305,13 +180,12 @@ where
305180 let incremental_code_splitting = compilation
306181 . incremental
307182 . passes_enabled ( IncrementalPasses :: BUILD_CHUNK_GRAPH ) ;
308- let new_code_splitting = compilation. options . experiments . parallel_code_splitting ;
309183 let no_change = compilation
310184 . build_chunk_graph_artifact
311185 . code_splitting_cache
312186 . can_skip_rebuilding ( compilation) ;
313187
314- if ( incremental_code_splitting && !new_code_splitting ) || no_change {
188+ if incremental_code_splitting || no_change {
315189 let cache = & mut compilation. build_chunk_graph_artifact . code_splitting_cache ;
316190 rayon:: scope ( |s| {
317191 s. spawn ( |_| compilation. chunk_by_ukey = cache. chunk_by_ukey . clone ( ) ) ;
0 commit comments