Convert finishModules hook to be an AsyncSeries

This commit is contained in:
Matt Jones 2019-04-01 09:46:08 +11:00
parent dc26688731
commit ea172ec5fd
2 changed files with 19 additions and 13 deletions

View File

@ -238,8 +238,8 @@ class Compilation extends Tapable {
"module"
]),
/** @type {SyncHook<Module[]>} */
finishModules: new SyncHook(["modules"]),
/** @type {AsyncSeriesHook<Module[]>} */
finishModules: new AsyncSeriesHook(["modules"]),
/** @type {SyncHook<Module>} */
finishRebuildingModule: new SyncHook(["module"]),
/** @type {SyncHook} */
@ -1158,14 +1158,18 @@ class Compilation extends Tapable {
});
}
finish() {
finish(callback) {
const modules = this.modules;
this.hooks.finishModules.call(modules);
this.hooks.finishModules.callAsync(modules, err => {
if (err) return callback(err);
for (let index = 0; index < modules.length; index++) {
const module = modules[index];
this.reportDependencyErrorsAndWarnings(module, [module]);
}
for (let index = 0; index < modules.length; index++) {
const module = modules[index];
this.reportDependencyErrorsAndWarnings(module, [module]);
}
callback();
});
}
unseal() {

View File

@ -619,15 +619,17 @@ class Compiler extends Tapable {
this.hooks.make.callAsync(compilation, err => {
if (err) return callback(err);
compilation.finish();
compilation.seal(err => {
compilation.finish(err => {
if (err) return callback(err);
this.hooks.afterCompile.callAsync(compilation, err => {
compilation.seal(err => {
if (err) return callback(err);
return callback(null, compilation);
this.hooks.afterCompile.callAsync(compilation, err => {
if (err) return callback(err);
return callback(null, compilation);
});
});
});
});