@@ -94,9 +94,6 @@ function evalDependencyGraph({loaderContext, src, filename, publicPath = ""}) {
94
94
}
95
95
96
96
async function evalModule ( src , filename ) {
97
- const rndPlaceholder = "__EXTRACT_LOADER_PLACEHOLDER__" + rndNumber ( ) + rndNumber ( ) ;
98
- const rndPlaceholderPattern = new RegExp ( rndPlaceholder , "g" ) ;
99
-
100
97
src = babel . transform ( src , {
101
98
babelrc : false ,
102
99
presets : [
@@ -150,9 +147,12 @@ function evalDependencyGraph({loaderContext, src, filename, publicPath = ""}) {
150
147
return exports ;
151
148
}
152
149
150
+ const rndPlaceholder = "__EXTRACT_LOADER_PLACEHOLDER__" + rndNumber ( ) + rndNumber ( ) ;
151
+
153
152
newDependencies . push ( {
154
153
absolutePath,
155
154
absoluteRequest : loaders + absolutePath + query ,
155
+ rndPlaceholder,
156
156
} ) ;
157
157
158
158
return rndPlaceholder ;
@@ -169,10 +169,11 @@ function evalDependencyGraph({loaderContext, src, filename, publicPath = ""}) {
169
169
} )
170
170
) ;
171
171
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 ) ;
176
177
177
178
moduleCache . set ( filename , extractedContent ) ;
178
179
0 commit comments