Skip to content

Commit

Permalink
Merge pull request #860 from embroider-build/add-better-error-throwing
Browse files Browse the repository at this point in the history
Ensure all errors are reported when an error occurs in webpack
  • Loading branch information
thoov committed Jun 18, 2021
2 parents 7460fce + 98ae4a4 commit 505560c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
2 changes: 2 additions & 0 deletions packages/webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@
"@embroider/hbs-loader": "0.42.0",
"@types/loader-utils": "^2.0.2",
"@types/source-map": "^0.5.7",
"@types/supports-color": "^8.1.0",
"babel-core": "^6.26.3",
"babel-loader": "^8.2.2",
"babel-preset-env": "^1.7.0",
"supports-color": "^8.1.0",
"css-loader": "^5.2.6",
"csso": "^4.2.0",
"debug": "^4.3.2",
Expand Down
14 changes: 13 additions & 1 deletion packages/webpack/src/ember-webpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { Options, BabelLoaderOptions } from './options';
import crypto from 'crypto';
import type { HbsLoaderConfig } from '@embroider/hbs-loader';
import semverSatisfies from 'semver/functions/satisfies';
import supportsColor from 'supports-color';

const debug = makeDebug('embroider:debug');

Expand Down Expand Up @@ -456,11 +457,22 @@ const Webpack: PackagerConstructor<Options> = class Webpack implements Packager
throw new Error('bug: no stats and no err');
}
if (stats.hasErrors()) {
// write all the stats output to the console
this.consoleWrite(
stats.toString({
color: Boolean(supportsColor.stdout),
})
);

// 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());
this.consoleWrite(
stats.toString({
color: Boolean(supportsColor.stdout),
})
);
}
resolve(stats.toJson());
} catch (e) {
Expand Down
7 changes: 6 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2481,6 +2481,11 @@
dependencies:
strip-bom "*"

"@types/supports-color@^8.1.0":
version "8.1.0"
resolved "https://registry.yarnpkg.com/@types/supports-color/-/supports-color-8.1.0.tgz#d25609c0c07a257dbc460cea4e693abf78fe6aef"
integrity sha512-yuaTiC8EqSvcb03zAsCXySH18CUcHNJFvOoqCJTMMKG3o5E4Jgnr1ycDR2v1BK9Cj56iMiYgjqX98eiWjRsBeg==

"@types/symlink-or-copy@^1.2.0":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@types/symlink-or-copy/-/symlink-or-copy-1.2.0.tgz#4151a81b4052c80bc2becbae09f3a9ec010a9c7a"
Expand Down Expand Up @@ -17724,7 +17729,7 @@ supports-color@^7.1.0:
dependencies:
has-flag "^4.0.0"

supports-color@^8.0.0:
supports-color@^8.0.0, supports-color@^8.1.0:
version "8.1.1"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-8.1.1.tgz#cd6fc17e28500cff56c1b86c0a7fd4a54a73005c"
integrity sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==
Expand Down

0 comments on commit 505560c

Please sign in to comment.