11use std:: {
22 collections:: HashSet ,
3- sync:: atomic:: { AtomicBool , Ordering } ,
3+ sync:: {
4+ Arc ,
5+ atomic:: { AtomicBool , Ordering } ,
6+ } ,
47} ;
58
69use rspack_collections:: {
@@ -19,7 +22,7 @@ use rspack_regex::RspackRegex;
1922const MIN_CSS_CHUNK_SIZE : f64 = 30_f64 * 1024_f64 ;
2023const MAX_CSS_CHUNK_SIZE : f64 = 100_f64 * 1024_f64 ;
2124
22- fn is_global_css ( name_for_condition : & Option < Box < str > > ) -> bool {
25+ fn is_global_css ( name_for_condition : Option < & str > ) -> bool {
2326 name_for_condition. as_ref ( ) . is_some_and ( |s| {
2427 !s. ends_with ( ".module.css" ) && !s. ends_with ( ".module.scss" ) && !s. ends_with ( ".module.sass" )
2528 } )
@@ -145,7 +148,7 @@ async fn optimize_chunks(&self, compilation: &mut Compilation) -> Result<Option<
145148 chunk_states. insert ( * chunk_ukey, chunk_state) ;
146149 }
147150
148- let module_infos: IdentifierMap < ( f64 , Option < Box < str > > ) > = {
151+ let module_infos: IdentifierMap < ( f64 , Option < Arc < str > > ) > = {
149152 let module_graph = compilation. get_module_graph ( ) ;
150153 let mut result = IdentifierMap :: default ( ) ;
151154 for module_identifier in chunk_states_by_module. keys ( ) {
@@ -154,7 +157,10 @@ async fn optimize_chunks(&self, compilation: &mut Compilation) -> Result<Option<
154157 . module_by_identifier ( module_identifier)
155158 . unwrap ( ) ;
156159 let size = module. size ( None , None ) ;
157- result. insert ( * module_identifier, ( size, module. name_for_condition ( ) ) ) ;
160+ result. insert (
161+ * module_identifier,
162+ ( size, module. name_for_condition ( ) . cloned ( ) ) ,
163+ ) ;
158164 }
159165 result
160166 } ;
@@ -221,7 +227,13 @@ async fn optimize_chunks(&self, compilation: &mut Compilation) -> Result<Option<
221227 remaining_modules. shift_remove ( & start_module_identifier) ;
222228
223229 #[ allow( clippy:: unwrap_used) ]
224- let mut global_css_mode = is_global_css ( & module_infos. get ( & start_module_identifier) . unwrap ( ) . 1 ) ;
230+ let mut global_css_mode = is_global_css (
231+ module_infos
232+ . get ( & start_module_identifier)
233+ . unwrap ( )
234+ . 1
235+ . as_deref ( ) ,
236+ ) ;
225237
226238 // The current position of processing in all selected chunks
227239 #[ allow( clippy:: unwrap_used) ]
@@ -324,7 +336,13 @@ async fn optimize_chunks(&self, compilation: &mut Compilation) -> Result<Option<
324336
325337 // Global CSS must not leak into unrelated chunks
326338 #[ allow( clippy:: unwrap_used) ]
327- let is_global = is_global_css ( & module_infos. get ( & next_module_identifier) . unwrap ( ) . 1 ) ;
339+ let is_global = is_global_css (
340+ module_infos
341+ . get ( & next_module_identifier)
342+ . unwrap ( )
343+ . 1
344+ . as_deref ( ) ,
345+ ) ;
328346 if is_global && global_css_mode && all_chunk_states. len ( ) != next_chunk_states. len ( ) {
329347 // Fast check: chunk groups need to be identical
330348 continue ;
0 commit comments