@@ -28,7 +28,7 @@ class Compiler extends Tapable {
2828 super ( ) ;
2929 this . hooks = {
3030 shouldEmit : new SyncBailHook ( [ "compilation" ] ) ,
31- done : new SyncHook ( [ "stats" ] ) ,
31+ done : new AsyncSeriesHook ( [ "stats" ] ) ,
3232 additionalPass : new AsyncSeriesHook ( [ ] ) ,
3333 beforeRun : new AsyncSeriesHook ( [ "compilation" ] ) ,
3434 run : new AsyncSeriesHook ( [ "compilation" ] ) ,
@@ -171,8 +171,11 @@ class Compiler extends Tapable {
171171 const stats = new Stats ( compilation ) ;
172172 stats . startTime = startTime ;
173173 stats . endTime = Date . now ( ) ;
174- this . hooks . done . call ( stats ) ;
175- return callback ( null , stats ) ;
174+ this . hooks . done . callAsync ( stats , err => {
175+ if ( err ) return callback ( err ) ;
176+ return callback ( null , stats ) ;
177+ } ) ;
178+ return ;
176179 }
177180
178181 this . emitAssets ( compilation , err => {
@@ -184,11 +187,13 @@ class Compiler extends Tapable {
184187 const stats = new Stats ( compilation ) ;
185188 stats . startTime = startTime ;
186189 stats . endTime = Date . now ( ) ;
187- this . hooks . done . call ( stats ) ;
188-
189- this . hooks . additionalPass . callAsync ( err => {
190+ this . hooks . done . callAsync ( stats , err => {
190191 if ( err ) return callback ( err ) ;
191- this . compile ( onCompiled ) ;
192+
193+ this . hooks . additionalPass . callAsync ( err => {
194+ if ( err ) return callback ( err ) ;
195+ this . compile ( onCompiled ) ;
196+ } ) ;
192197 } ) ;
193198 return ;
194199 }
@@ -199,8 +204,10 @@ class Compiler extends Tapable {
199204 const stats = new Stats ( compilation ) ;
200205 stats . startTime = startTime ;
201206 stats . endTime = Date . now ( ) ;
202- this . hooks . done . call ( stats ) ;
203- return callback ( null , stats ) ;
207+ this . hooks . done . callAsync ( stats , err => {
208+ if ( err ) return callback ( err ) ;
209+ return callback ( null , stats ) ;
210+ } ) ;
204211 } ) ;
205212 } ) ;
206213 } ;
0 commit comments