Skip to content

Commit e45652d

Browse files
committed
Don't use random placeholders
1 parent 8500840 commit e45652d

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/extractLoader.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -147,15 +147,15 @@ function evalDependencyGraph({loaderContext, src, filename, publicPath = ""}) {
147147
return exports;
148148
}
149149

150-
const rndPlaceholder = "__EXTRACT_LOADER_PLACEHOLDER__" + rndNumber() + rndNumber();
150+
const extractPlaceholder = "__EXTRACT_LOADER_PLACEHOLDER__" + counterNumber() + "__";
151151

152152
newDependencies.push({
153153
absolutePath,
154154
absoluteRequest: loaders + absolutePath + query,
155-
rndPlaceholder,
155+
extractPlaceholder,
156156
});
157157

158-
return rndPlaceholder;
158+
return extractPlaceholder;
159159
},
160160
});
161161

@@ -170,7 +170,7 @@ function evalDependencyGraph({loaderContext, src, filename, publicPath = ""}) {
170170
);
171171
const contentWithPlaceholders = extractExports(sandbox.module.exports);
172172
const extractedContent = extractedDependencyContent.reduce((content, dependencyContent, idx) => {
173-
const pattern = new RegExp(newDependencies[idx].rndPlaceholder, "g");
173+
const pattern = new RegExp(newDependencies[idx].extractPlaceholder, "g");
174174

175175
return content.replace(pattern, dependencyContent);
176176
}, contentWithPlaceholders);
@@ -183,13 +183,13 @@ function evalDependencyGraph({loaderContext, src, filename, publicPath = ""}) {
183183
return evalModule(src, filename);
184184
}
185185

186+
let counter = 0;
187+
186188
/**
187189
* @returns {string}
188190
*/
189-
function rndNumber() {
190-
return Math.random()
191-
.toString()
192-
.slice(2);
191+
function counterNumber() {
192+
return (counter++).toString(10);
193193
}
194194

195195
// getPublicPath() encapsulates the complexity of reading the publicPath from the current

0 commit comments

Comments
 (0)