From 9df98e65f842cf3acae09cbdd969966f42d64469 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Sat, 14 Oct 2017 18:40:54 +0200 Subject: update dependencies --- node_modules/webpack/lib/CachePlugin.js | 34 ++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) (limited to 'node_modules/webpack/lib/CachePlugin.js') diff --git a/node_modules/webpack/lib/CachePlugin.js b/node_modules/webpack/lib/CachePlugin.js index 1b8d6a30e..9c19b8140 100644 --- a/node_modules/webpack/lib/CachePlugin.js +++ b/node_modules/webpack/lib/CachePlugin.js @@ -18,15 +18,31 @@ class CachePlugin { c.apply(new CachePlugin(this.cache[idx] = this.cache[idx] || {})); }); } else { - compiler.plugin("compilation", compilation => { - if(!compilation.notCacheable) { - compilation.cache = this.cache; - } else if(this.watching) { - compilation.warnings.push( - new Error(`CachePlugin - Cache cannot be used because of: ${compilation.notCacheable}`) - ); - } - }); + const registerCacheToCompiler = (compiler, cache) => { + compiler.plugin("this-compilation", compilation => { + // TODO remove notCacheable for webpack 4 + if(!compilation.notCacheable) { + compilation.cache = cache; + compilation.plugin("child-compiler", (childCompiler, compilerName, compilerIndex) => { + if(cache) { + let childCache; + if(!cache.children) cache.children = {}; + if(!cache.children[compilerName]) cache.children[compilerName] = []; + if(cache.children[compilerName][compilerIndex]) + childCache = cache.children[compilerName][compilerIndex]; + else + cache.children[compilerName].push(childCache = {}); + registerCacheToCompiler(childCompiler, childCache); + } + }); + } else if(this.watching) { + compilation.warnings.push( + new Error(`CachePlugin - Cache cannot be used because of: ${compilation.notCacheable}`) + ); + } + }); + }; + registerCacheToCompiler(compiler, this.cache); compiler.plugin("watch-run", (compiler, callback) => { this.watching = true; callback(); -- cgit v1.2.3