@@ -20,26 +20,19 @@ class CachePlugin {
2020 } else {
2121 const registerCacheToCompiler = ( compiler , cache ) => {
2222 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- }
23+ compilation . cache = cache ;
24+ compilation . plugin ( "child-compiler" , ( childCompiler , compilerName , compilerIndex ) => {
25+ if ( cache ) {
26+ let childCache ;
27+ if ( ! cache . children ) cache . children = { } ;
28+ if ( ! cache . children [ compilerName ] ) cache . children [ compilerName ] = [ ] ;
29+ if ( cache . children [ compilerName ] [ compilerIndex ] )
30+ childCache = cache . children [ compilerName ] [ compilerIndex ] ;
31+ else
32+ cache . children [ compilerName ] . push ( childCache = { } ) ;
33+ registerCacheToCompiler ( childCompiler , childCache ) ;
34+ }
35+ } ) ;
4336 } ) ;
4437 } ;
4538 registerCacheToCompiler ( compiler , this . cache ) ;
0 commit comments