@@ -148,6 +148,8 @@ pub struct NormalModule {
148
148
build_info : BuildInfo ,
149
149
build_meta : BuildMeta ,
150
150
parsed : bool ,
151
+
152
+ name_for_condition : Arc < str > ,
151
153
}
152
154
153
155
static DEBUG_ID : AtomicUsize = AtomicUsize :: new ( 1 ) ;
@@ -185,6 +187,16 @@ impl NormalModule {
185
187
) -> Self {
186
188
let module_type = module_type. into ( ) ;
187
189
let id = Self :: create_id ( & module_type, layer. as_ref ( ) , & request) ;
190
+
191
+ // Align with https://github.com/webpack/webpack/blob/8241da7f1e75c5581ba535d127fa66aeb9eb2ac8/lib/NormalModule.js#L375
192
+ let resource = resource_data. resource ( ) ;
193
+ let idx = resource. find ( '?' ) ;
194
+ let name_for_condition = if let Some ( idx) = idx {
195
+ Arc :: from ( resource[ ..idx] . to_string ( ) )
196
+ } else {
197
+ Arc :: from ( resource. to_string ( ) )
198
+ } ;
199
+
188
200
Self {
189
201
blocks : Vec :: new ( ) ,
190
202
dependencies : Vec :: new ( ) ,
@@ -214,6 +226,8 @@ impl NormalModule {
214
226
build_meta : Default :: default ( ) ,
215
227
parsed : false ,
216
228
source_map_kind : SourceMapKind :: empty ( ) ,
229
+
230
+ name_for_condition,
217
231
}
218
232
}
219
233
@@ -668,15 +682,8 @@ impl Module for NormalModule {
668
682
Ok ( hasher. digest ( & compilation. options . output . hash_digest ) )
669
683
}
670
684
671
- fn name_for_condition ( & self ) -> Option < Box < str > > {
672
- // Align with https://github.com/webpack/webpack/blob/8241da7f1e75c5581ba535d127fa66aeb9eb2ac8/lib/NormalModule.js#L375
673
- let resource = self . resource_data . resource ( ) ;
674
- let idx = resource. find ( '?' ) ;
675
- if let Some ( idx) = idx {
676
- Some ( resource[ ..idx] . into ( ) )
677
- } else {
678
- Some ( resource. into ( ) )
679
- }
685
+ fn name_for_condition ( & self ) -> Option < & Arc < str > > {
686
+ Some ( & self . name_for_condition )
680
687
}
681
688
682
689
fn lib_ident ( & self , options : LibIdentOptions ) -> Option < Cow < ' _ , str > > {
0 commit comments