@@ -148,6 +148,8 @@ pub struct NormalModule {
148148 build_info : BuildInfo ,
149149 build_meta : BuildMeta ,
150150 parsed : bool ,
151+
152+ name_for_condition : Arc < str > ,
151153}
152154
153155static DEBUG_ID : AtomicUsize = AtomicUsize :: new ( 1 ) ;
@@ -185,6 +187,16 @@ impl NormalModule {
185187 ) -> Self {
186188 let module_type = module_type. into ( ) ;
187189 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+
188200 Self {
189201 blocks : Vec :: new ( ) ,
190202 dependencies : Vec :: new ( ) ,
@@ -214,6 +226,8 @@ impl NormalModule {
214226 build_meta : Default :: default ( ) ,
215227 parsed : false ,
216228 source_map_kind : SourceMapKind :: empty ( ) ,
229+
230+ name_for_condition,
217231 }
218232 }
219233
@@ -668,15 +682,8 @@ impl Module for NormalModule {
668682 Ok ( hasher. digest ( & compilation. options . output . hash_digest ) )
669683 }
670684
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 )
680687 }
681688
682689 fn lib_ident ( & self , options : LibIdentOptions ) -> Option < Cow < ' _ , str > > {
0 commit comments