Skip to content
Permalink
Browse files

Convert finishModules hook to be an AsyncSeries

  • Loading branch information...
mattsjones committed Mar 31, 2019
1 parent dc26688 commit ea172ec5fdebb77647adde4c8406e9d0b2bbd48c
Showing with 19 additions and 13 deletions.
  1. +12 −8 lib/Compilation.js
  2. +7 −5 lib/Compiler.js
@@ -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() {
@@ -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);
});
});
});
});

0 comments on commit ea172ec

Please sign in to comment.
You can’t perform that action at this time.