webpack 3.5.6 → 3.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -537,7 +537,7 @@ module.exports = function(yargs, argv, convertOptions) {
537
537
  if(i < 0 || (j >= 0 && j < i)) {
538
538
  var resolved = path.resolve(content);
539
539
  if(fs.existsSync(resolved)) {
540
- addTo("main", resolved);
540
+ addTo("main", `${resolved}${fs.statSync(resolved).isDirectory() ? path.sep : ""}`);
541
541
  } else {
542
542
  addTo("main", content);
543
543
  }
@@ -18,15 +18,31 @@ class CachePlugin {
18
18
  c.apply(new CachePlugin(this.cache[idx] = this.cache[idx] || {}));
19
19
  });
20
20
  } else {
21
- compiler.plugin("compilation", compilation => {
22
- if(!compilation.notCacheable) {
23
- compilation.cache = this.cache;
24
- } else if(this.watching) {
25
- compilation.warnings.push(
26
- new Error(`CachePlugin - Cache cannot be used because of: ${compilation.notCacheable}`)
27
- );
28
- }
29
- });
21
+ const registerCacheToCompiler = (compiler, cache) => {
22
+ compiler.plugin("this-compilation", compilation => {
23
+ // TODO remove notCacheable for webpack 4
24
+ if(!compilation.notCacheable) {
25
+ compilation.cache = cache;
26
+ compilation.plugin("child-compiler", (childCompiler, compilerName, compilerIndex) => {
27
+ if(cache) {
28
+ let childCache;
29
+ if(!cache.children) cache.children = {};
30
+ if(!cache.children[compilerName]) cache.children[compilerName] = [];
31
+ if(cache.children[compilerName][compilerIndex])
32
+ childCache = cache.children[compilerName][compilerIndex];
33
+ else
34
+ cache.children[compilerName].push(childCache = {});
35
+ registerCacheToCompiler(childCompiler, childCache);
36
+ }
37
+ });
38
+ } else if(this.watching) {
39
+ compilation.warnings.push(
40
+ new Error(`CachePlugin - Cache cannot be used because of: ${compilation.notCacheable}`)
41
+ );
42
+ }
43
+ });
44
+ };
45
+ registerCacheToCompiler(compiler, this.cache);
30
46
  compiler.plugin("watch-run", (compiler, callback) => {
31
47
  this.watching = true;
32
48
  callback();
package/lib/Compiler.js CHANGED
@@ -438,21 +438,15 @@ class Compiler extends Tapable {
438
438
  else
439
439
  this.records[relativeCompilerName].push(childCompiler.records = {});
440
440
 
441
- if(this.cache) {
442
- if(!this.cache.children) this.cache.children = {};
443
- if(!this.cache.children[compilerName]) this.cache.children[compilerName] = [];
444
- if(this.cache.children[compilerName][compilerIndex])
445
- childCompiler.cache = this.cache.children[compilerName][compilerIndex];
446
- else
447
- this.cache.children[compilerName].push(childCompiler.cache = {});
448
- }
449
-
450
441
  childCompiler.options = Object.create(this.options);
451
442
  childCompiler.options.output = Object.create(childCompiler.options.output);
452
443
  for(const name in outputOptions) {
453
444
  childCompiler.options.output[name] = outputOptions[name];
454
445
  }
455
446
  childCompiler.parentCompilation = compilation;
447
+
448
+ compilation.applyPlugins("child-compiler", childCompiler, compilerName, compilerIndex);
449
+
456
450
  return childCompiler;
457
451
  }
458
452