@@ -10,6 +10,8 @@ var Stats = require("./Stats");
1010var NormalModuleFactory = require ( "./NormalModuleFactory" ) ;
1111var ContextModuleFactory = require ( "./ContextModuleFactory" ) ;
1212
13+ var makePathsRelative = require ( "./util/identifier" ) . makePathsRelative ;
14+
1315function Watching ( compiler , watchOptions , handler ) {
1416 this . startTime = null ;
1517 this . invalid = false ;
@@ -407,7 +409,7 @@ Compiler.prototype.readRecords = function readRecords(callback) {
407409 } ) ;
408410} ;
409411
410- Compiler . prototype . createChildCompiler = function ( compilation , compilerName , outputOptions , plugins ) {
412+ Compiler . prototype . createChildCompiler = function ( compilation , compilerName , compilerIndex , outputOptions , plugins ) {
411413 var childCompiler = new Compiler ( ) ;
412414 if ( Array . isArray ( plugins ) ) {
413415 plugins . forEach ( plugin => childCompiler . apply ( plugin ) ) ;
@@ -423,8 +425,23 @@ Compiler.prototype.createChildCompiler = function(compilation, compilerName, out
423425 childCompiler . resolvers = this . resolvers ;
424426 childCompiler . fileTimestamps = this . fileTimestamps ;
425427 childCompiler . contextTimestamps = this . contextTimestamps ;
426- if ( ! this . records [ compilerName ] ) this . records [ compilerName ] = [ ] ;
427- this . records [ compilerName ] . push ( childCompiler . records = { } ) ;
428+
429+ var relativeCompilerName = makePathsRelative ( this . context , compilerName ) ;
430+ if ( ! this . records [ relativeCompilerName ] ) this . records [ relativeCompilerName ] = [ ] ;
431+ if ( this . records [ relativeCompilerName ] [ compilerIndex ] )
432+ childCompiler . records = this . records [ relativeCompilerName ] [ compilerIndex ] ;
433+ else
434+ this . records [ relativeCompilerName ] . push ( childCompiler . records = { } ) ;
435+
436+ if ( this . cache ) {
437+ if ( ! this . cache . children ) this . cache . children = { } ;
438+ if ( ! this . cache . children [ compilerName ] ) this . cache . children [ compilerName ] = [ ] ;
439+ if ( this . cache . children [ compilerName ] [ compilerIndex ] )
440+ childCompiler . cache = this . cache . children [ compilerName ] [ compilerIndex ] ;
441+ else
442+ this . cache . children [ compilerName ] . push ( childCompiler . cache = { } ) ;
443+ }
444+
428445 childCompiler . options = Object . create ( this . options ) ;
429446 childCompiler . options . output = Object . create ( childCompiler . options . output ) ;
430447 for ( name in outputOptions ) {
0 commit comments