Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
setChangedFiles(compilation, file) {
const original = compilation.assets[file];
const originalSource = original.source();
const originalMap = original.map();
const result = new ReplaceSource(original);
const regex = /__webpackManifest__\s*=\s*\[\s*\]/g; // eslint-disable-line
const files = this.hotFiles.concat(this.failedFiles);
const changedFiles = `['${files.join("', '")}']`;
const replacement = `__webpackManifest__ = ${changedFiles}`;
let match;
while ((match = regex.exec(originalSource)) !== null) { // eslint-disable-line no-cond-assign
const start = match.index;
const end = match.index + (match[0].length - 1);
result.replace(start, end, replacement);
}
const resultSource = result.source();
const resultMap = result.map();
compilation.assets[file] = new SourceMapSource( // eslint-disable-line no-param-reassign