Skip to content

Commit

Permalink
Merge pull request #838 from embroider-build/fix-webpack-run-cb
Browse files Browse the repository at this point in the history
  • Loading branch information
rwjblue authored Jun 7, 2021
2 parents 87548d4 + 633f740 commit bb10b4c
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions packages/webpack/src/ember-webpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -443,27 +443,29 @@ const Webpack: PackagerConstructor<Options> = class Webpack implements Packager
private runWebpack(webpack: webpack.MultiCompiler): Promise<webpack.StatsCompilation> {
return new Promise((resolve, reject) => {
webpack.run((err, stats) => {
if (err) {
if (stats) {
try {
if (err) {
if (stats) {
this.consoleWrite(stats.toString());
}
throw err;
}
if (!stats) {
// this doesn't really happen, but webpack's types imply that it
// could, so we just satisfy typescript here
throw new Error('bug: no stats and no err');
}
if (stats.hasErrors()) {
// the typing for MultiCompiler are all foobared.
throw this.findBestError(flatMap((stats as any).stats, s => s.compilation.errors));
}
if (stats.hasWarnings() || process.env.VANILLA_VERBOSE) {
this.consoleWrite(stats.toString());
}
reject(err);
return;
}
if (!stats) {
// this doesn't really happen, but webpack's types imply that it
// could, so we just satisfy typescript here
throw new Error('bug: no stats and no err');
}
if (stats.hasErrors()) {
// the typing for MultiCompiler are all foobared.
reject(this.findBestError(flatMap((stats as any).stats, s => s.compilation.errors)));
return;
}
if (stats.hasWarnings() || process.env.VANILLA_VERBOSE) {
this.consoleWrite(stats.toString());
resolve(stats.toJson());
} catch (e) {
reject(e);
}
resolve(stats.toJson());
});
});
}
Expand Down

0 comments on commit bb10b4c

Please sign in to comment.