From 6fdcef3c6cf0d62778c84ebb2a1838906e674f81 Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Thu, 17 Jun 2021 18:27:13 -0400 Subject: [PATCH] Ensure all errors are reported when an error occurs in webpack 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). --- packages/webpack/package.json | 2 ++ packages/webpack/src/ember-webpack.ts | 10 ++++++- yarn.lock | 41 ++++++++++++++++++++++++++- 3 files changed, 51 insertions(+), 2 deletions(-) diff --git a/packages/webpack/package.json b/packages/webpack/package.json index 6a48994e50..d836646390 100644 --- a/packages/webpack/package.json +++ b/packages/webpack/package.json @@ -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", diff --git a/packages/webpack/src/ember-webpack.ts b/packages/webpack/src/ember-webpack.ts index 1ce633e49e..7c08777e6e 100644 --- a/packages/webpack/src/ember-webpack.ts +++ b/packages/webpack/src/ember-webpack.ts @@ -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'); @@ -456,11 +457,18 @@ const Webpack: PackagerConstructor = 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) { diff --git a/yarn.lock b/yarn.lock index 9398f1bf76..5bc32b2ccb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1438,6 +1438,18 @@ resolve "^1.8.1" semver "^7.3.2" +"@embroider/macros@0.41.0", "@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" @@ -1467,6 +1479,28 @@ semver "^7.3.2" typescript-memoize "^1.0.0-alpha.3" +"@embroider/shared-internals@0.41.0": + 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/webpack@0.40.0": version "0.40.0" resolved "https://registry.yarnpkg.com/@embroider/webpack/-/webpack-0.40.0.tgz#cd4c67d224fda29f940df0cb5ebae911a386933d" @@ -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" @@ -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==