@@ -313,12 +313,12 @@ module.exports = class MultiCompiler {
313313 /**
314314 * @template SetupResult
315315 * @param {function(Compiler, number, Callback<Stats>, function(): boolean, function(): void, function(): void): SetupResult } setup setup a single compiler
316- * @param {function(Compiler, Callback<Stats>): void } run run/continue a single compiler
316+ * @param {function(Compiler, SetupResult, Callback<Stats>): void } run run/continue a single compiler
317317 * @param {Callback<MultiStats> } callback callback when all compilers are done, result includes Stats of all changed compilers
318318 * @returns {SetupResult[] } result of setup
319319 */
320320 _runGraph ( setup , run , callback ) {
321- /** @typedef {{ compiler: Compiler, result: Stats, state: "pending" | "blocked" | "queued" | "starting" | "running" | "running-outdated" | "done", children: Node[], parents: Node[] } } Node */
321+ /** @typedef {{ compiler: Compiler, setupResult: SetupResult, result: Stats, state: "pending" | "blocked" | "queued" | "starting" | "running" | "running-outdated" | "done", children: Node[], parents: Node[] } } Node */
322322
323323 // State transitions for nodes:
324324 // -> blocked (initial)
@@ -335,6 +335,7 @@ module.exports = class MultiCompiler {
335335 /** @type {Node[] } */
336336 const nodes = this . compilers . map ( compiler => ( {
337337 compiler,
338+ setupResult : undefined ,
338339 result : undefined ,
339340 state : "blocked" ,
340341 children : [ ] ,
@@ -444,14 +445,14 @@ module.exports = class MultiCompiler {
444445 const setupResults = [ ] ;
445446 nodes . forEach ( ( node , i ) => {
446447 setupResults . push (
447- setup (
448+ ( node . setupResult = setup (
448449 node . compiler ,
449450 i ,
450451 nodeDone . bind ( null , node ) ,
451452 ( ) => node . state !== "starting" && node . state !== "running" ,
452453 ( ) => nodeChange ( node ) ,
453454 ( ) => nodeInvalid ( node )
454- )
455+ ) )
455456 ) ;
456457 } ) ;
457458 let processing = true ;
@@ -470,7 +471,7 @@ module.exports = class MultiCompiler {
470471 ) {
471472 running ++ ;
472473 node . state = "starting" ;
473- run ( node . compiler , nodeDone . bind ( null , node ) ) ;
474+ run ( node . compiler , node . setupResult , nodeDone . bind ( null , node ) ) ;
474475 node . state = "running" ;
475476 }
476477 }
@@ -522,8 +523,9 @@ module.exports = class MultiCompiler {
522523 }
523524 return watching ;
524525 } ,
525- ( compiler , initial , callback ) => {
526- if ( ! compiler . watching . running ) compiler . watching . invalidate ( ) ;
526+ ( compiler , watching , callback ) => {
527+ if ( compiler . watching !== watching ) return ;
528+ if ( ! watching . running ) watching . invalidate ( ) ;
527529 } ,
528530 handler
529531 ) ;
@@ -546,7 +548,7 @@ module.exports = class MultiCompiler {
546548 if ( this . validateDependencies ( callback ) ) {
547549 this . _runGraph (
548550 ( ) => { } ,
549- ( compiler , callback ) => compiler . run ( callback ) ,
551+ ( compiler , setupResult , callback ) => compiler . run ( callback ) ,
550552 ( err , stats ) => {
551553 this . running = false ;
552554
0 commit comments