1
1
use std:: {
2
2
collections:: HashSet ,
3
- sync:: atomic:: { AtomicBool , Ordering } ,
3
+ sync:: {
4
+ Arc ,
5
+ atomic:: { AtomicBool , Ordering } ,
6
+ } ,
4
7
} ;
5
8
6
9
use rspack_collections:: {
@@ -19,7 +22,7 @@ use rspack_regex::RspackRegex;
19
22
const MIN_CSS_CHUNK_SIZE : f64 = 30_f64 * 1024_f64 ;
20
23
const MAX_CSS_CHUNK_SIZE : f64 = 100_f64 * 1024_f64 ;
21
24
22
- fn is_global_css ( name_for_condition : & Option < Box < str > > ) -> bool {
25
+ fn is_global_css ( name_for_condition : Option < & str > ) -> bool {
23
26
name_for_condition. as_ref ( ) . is_some_and ( |s| {
24
27
!s. ends_with ( ".module.css" ) && !s. ends_with ( ".module.scss" ) && !s. ends_with ( ".module.sass" )
25
28
} )
@@ -145,7 +148,7 @@ async fn optimize_chunks(&self, compilation: &mut Compilation) -> Result<Option<
145
148
chunk_states. insert ( * chunk_ukey, chunk_state) ;
146
149
}
147
150
148
- let module_infos: IdentifierMap < ( f64 , Option < Box < str > > ) > = {
151
+ let module_infos: IdentifierMap < ( f64 , Option < Arc < str > > ) > = {
149
152
let module_graph = compilation. get_module_graph ( ) ;
150
153
let mut result = IdentifierMap :: default ( ) ;
151
154
for module_identifier in chunk_states_by_module. keys ( ) {
@@ -154,7 +157,10 @@ async fn optimize_chunks(&self, compilation: &mut Compilation) -> Result<Option<
154
157
. module_by_identifier ( module_identifier)
155
158
. unwrap ( ) ;
156
159
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
+ ) ;
158
164
}
159
165
result
160
166
} ;
@@ -221,7 +227,13 @@ async fn optimize_chunks(&self, compilation: &mut Compilation) -> Result<Option<
221
227
remaining_modules. shift_remove ( & start_module_identifier) ;
222
228
223
229
#[ 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
+ ) ;
225
237
226
238
// The current position of processing in all selected chunks
227
239
#[ allow( clippy:: unwrap_used) ]
@@ -324,7 +336,13 @@ async fn optimize_chunks(&self, compilation: &mut Compilation) -> Result<Option<
324
336
325
337
// Global CSS must not leak into unrelated chunks
326
338
#[ 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
+ ) ;
328
346
if is_global && global_css_mode && all_chunk_states. len ( ) != next_chunk_states. len ( ) {
329
347
// Fast check: chunk groups need to be identical
330
348
continue ;
0 commit comments