@@ -94,9 +94,6 @@ function evalDependencyGraph({loaderContext, src, filename, publicPath = ""}) {
9494 }
9595
9696 async function evalModule ( src , filename ) {
97- const rndPlaceholder = "__EXTRACT_LOADER_PLACEHOLDER__" + rndNumber ( ) + rndNumber ( ) ;
98- const rndPlaceholderPattern = new RegExp ( rndPlaceholder , "g" ) ;
99-
10097 src = babel . transform ( src , {
10198 babelrc : false ,
10299 presets : [
@@ -150,9 +147,12 @@ function evalDependencyGraph({loaderContext, src, filename, publicPath = ""}) {
150147 return exports ;
151148 }
152149
150+ const rndPlaceholder = "__EXTRACT_LOADER_PLACEHOLDER__" + rndNumber ( ) + rndNumber ( ) ;
151+
153152 newDependencies . push ( {
154153 absolutePath,
155154 absoluteRequest : loaders + absolutePath + query ,
155+ rndPlaceholder,
156156 } ) ;
157157
158158 return rndPlaceholder ;
@@ -169,10 +169,11 @@ function evalDependencyGraph({loaderContext, src, filename, publicPath = ""}) {
169169 } )
170170 ) ;
171171 const contentWithPlaceholders = extractExports ( sandbox . module . exports ) ;
172- const extractedContent = contentWithPlaceholders . replace (
173- rndPlaceholderPattern ,
174- ( ) => extractedDependencyContent . shift ( )
175- ) ;
172+ const extractedContent = extractedDependencyContent . reduce ( ( content , dependencyContent , idx ) => {
173+ const pattern = new RegExp ( newDependencies [ idx ] . rndPlaceholder , "g" ) ;
174+
175+ return content . replace ( pattern , dependencyContent ) ;
176+ } , contentWithPlaceholders ) ;
176177
177178 moduleCache . set ( filename , extractedContent ) ;
178179
0 commit comments