Skip to content

Commit

Permalink
Ensure all errors are reported when an error occurs in webpack
Browse files Browse the repository at this point in the history
Prior to this we would emit only the first error, leading to **mega**
painful games of "whack-a-mole" (get error, fix error, do build, find
next error, fix error, do build, find yet another error).
  • Loading branch information
rwjblue committed Jun 17, 2021
1 parent f1b103a commit 6fdcef3
Show file tree
Hide file tree
Showing 3 changed files with 51 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
10 changes: 9 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,18 @@ 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
41 changes: 40 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1438,6 +1438,18 @@
resolve "^1.8.1"
semver "^7.3.2"

"@embroider/[email protected]", "@embroider/macros@^0.41.0":
version "0.41.0"
resolved "https://registry.yarnpkg.com/@embroider/macros/-/macros-0.41.0.tgz#3e78b6f388d7229906abf4c75edfff8bb0208aca"
integrity sha512-QISzwEEfLsskZeL0jyZDs1RoQSotwBWj+4upTogNHuxQP5j/9H3IMG/3QB1gh8GEpbudATb/cS4NDYK3UBxufw==
dependencies:
"@embroider/shared-internals" "0.41.0"
assert-never "^1.1.0"
ember-cli-babel "^7.23.0"
lodash "^4.17.10"
resolve "^1.8.1"
semver "^7.3.2"

"@embroider/sample-lib@link:test-packages/sample-lib":
version "0.0.0"

Expand Down Expand Up @@ -1467,6 +1479,28 @@
semver "^7.3.2"
typescript-memoize "^1.0.0-alpha.3"

"@embroider/[email protected]":
version "0.41.0"
resolved "https://registry.yarnpkg.com/@embroider/shared-internals/-/shared-internals-0.41.0.tgz#2553f026d4f48ea1fd11235501feb63bf49fa306"
integrity sha512-fiqUVB6cfh2UBEFE4yhT5EzagkZ1Q26+OhBV0nJszFEJZx4DqVIb3pxSSZ8P+HhpxuJsQ2XpMA/j02ZPFZfbdQ==
dependencies:
ember-rfc176-data "^0.3.17"
fs-extra "^7.0.1"
lodash "^4.17.10"
pkg-up "^3.1.0"
resolve-package-path "^1.2.2"
semver "^7.3.2"
typescript-memoize "^1.0.0-alpha.3"

"@embroider/util@^0.39.1 || ^0.40.0 || ^0.41.0", "@embroider/util@^0.41.0":
version "0.41.0"
resolved "https://registry.yarnpkg.com/@embroider/util/-/util-0.41.0.tgz#5324cb4742aa4ed8d613c4f88a466f73e4e6acc1"
integrity sha512-ytA3J/YfQh7FEUEBwz3ezTqQNm/S5et5rZw3INBIy4Ak4x0NXV/VXLjyL8mv3txL8fGknZTBdXEhDsHUKIq8SQ==
dependencies:
"@embroider/macros" "0.41.0"
broccoli-funnel "^3.0.5"
ember-cli-babel "^7.23.1"

"@embroider/[email protected]":
version "0.40.0"
resolved "https://registry.yarnpkg.com/@embroider/webpack/-/webpack-0.40.0.tgz#cd4c67d224fda29f940df0cb5ebae911a386933d"
Expand Down Expand Up @@ -2600,6 +2634,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 @@ -17870,7 +17909,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 6fdcef3

Please sign in to comment.