From 3a8ce1f68f6d54c82f14df2dcbb530c24c32af0b Mon Sep 17 00:00:00 2001 From: Steven Hargrove Date: Fri, 7 Jul 2017 22:29:07 -0400 Subject: [PATCH] fixed breaking change for MultiCompiler support --- src/index.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 1730f2b9..e36981ce 100644 --- a/src/index.js +++ b/src/index.js @@ -149,7 +149,10 @@ class UglifyJsPlugin { } apply(compiler) { - const requestShortener = new RequestShortener(compiler.context); + if (UglifyJsPlugin.appliedCompilers.has(compiler)) return; + UglifyJsPlugin.appliedCompilers.add(compiler); + + const requestShortener = new RequestShortener(compiler.context || process.cwd()); // Copy uglify options const uglifyOptions = UglifyJsPlugin.buildDefaultUglifyOptions(this.uglifyOptions); // Making sure output options exists if there is an extractComments options @@ -280,4 +283,11 @@ class UglifyJsPlugin { } } +Object.defineProperty(UglifyJsPlugin, 'appliedCompilers', { + enumerable: false, + configurable: false, + writable: false, + value: new WeakSet(), +}); + export default UglifyJsPlugin;