Skip to content
This repository has been archived by the owner on Dec 5, 2019. It is now read-only.

Commit

Permalink
changed __UglifyJsPlugin to use WeakSet
Browse files Browse the repository at this point in the history
  • Loading branch information
hulkish committed Jun 29, 2017
1 parent 7822c9f commit 14a621e
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ class UglifyJsPlugin {
// eslint-disable-next-line prefer-spread
files.push.apply(files, compilation.additionalChunkAssets);
const filteredFiles = files.filter(ModuleFilenameHelpers.matchObject.bind(undefined, options));
const uglifiedAssets = new WeakSet();
filteredFiles.forEach((file) => {
const oldWarnFunction = uglify.AST_Node.warn_function;
const warnings = [];
let sourceMap;
try {
const asset = compilation.assets[file];
if (asset.__UglifyJsPlugin) {
compilation.assets[file] = asset.__UglifyJsPlugin;
if (uglifiedAssets.has(asset)) {
return;
}
let input;
Expand Down Expand Up @@ -220,9 +220,7 @@ class UglifyJsPlugin {
}
}
}
compilation.assets[file] = outputSource;
asset.__UglifyJsPlugin = outputSource;

uglifiedAssets.add(compilation.assets[file] = outputSource);
if (warnings.length > 0) {
compilation.warnings.push(new Error(`${file} from UglifyJs\n${warnings.join('\n')}`));
}
Expand Down

0 comments on commit 14a621e

Please sign in to comment.