Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f7cbea5

Browse files
committedJul 3, 2020
fix(@angular-devkit/build-angular): show child compilation errors
Closes #17565 (cherry picked from commit 64a2686)
1 parent 00f74ce commit f7cbea5

File tree

2 files changed

+24
-7
lines changed
  • packages/angular_devkit/build_angular/src

2 files changed

+24
-7
lines changed
 

‎packages/angular_devkit/build_angular/src/angular-cli-files/utilities/stats.ts

+18-2
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,12 @@ export function statsWarningsToString(json: any, statsConfig: any) {
9494
const colors = statsConfig.colors;
9595
const rs = (x: string) => colors ? reset(x) : x;
9696
const y = (x: string) => colors ? bold(yellow(x)) : x;
97+
const warnings = [...json.warnings];
98+
if (json.children) {
99+
warnings.push(...json.children.map((c: any) => c.warnings));
100+
}
97101

98-
return rs('\n' + json.warnings
102+
return rs('\n' + warnings
99103
.map((warning: any) => `${warning}`)
100104
.filter((warning: string) => !ERRONEOUS_WARNINGS.some((erroneous) => erroneous.test(warning)))
101105
.map((warning: string) => y(`WARNING in ${warning}`))
@@ -106,6 +110,18 @@ export function statsErrorsToString(json: any, statsConfig: any) {
106110
const colors = statsConfig.colors;
107111
const rs = (x: string) => colors ? reset(x) : x;
108112
const r = (x: string) => colors ? bold(red(x)) : x;
113+
const errors = [...json.errors];
114+
if (json.children) {
115+
errors.push(...json.children.map((c: any) => c.errors));
116+
}
117+
118+
return rs('\n' + errors.map((error: any) => r(`ERROR in ${error}`)).join('\n'));
119+
}
120+
121+
export function statsHasErrors(json: any): boolean {
122+
return json.errors.length > 0 || !!json.children?.some((c: any) => c.errors.length);
123+
}
109124

110-
return rs('\n' + json.errors.map((error: any) => r(`ERROR in ${error}`)).join('\n'));
125+
export function statsHasWarnings(json: any): boolean {
126+
return json.warnings.length > 0 || !!json.children?.some((c: any) => c.warnings.length);
111127
}

‎packages/angular_devkit/build_angular/src/browser/index.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ import {
3939
generateBuildStats,
4040
generateBundleStats,
4141
statsErrorsToString,
42+
statsHasErrors,
43+
statsHasWarnings,
4244
statsToString,
4345
statsWarningsToString,
4446
} from '../angular-cli-files/utilities/stats';
@@ -302,10 +304,10 @@ export function buildWebpackBrowser(
302304
if (!success && useBundleDownleveling) {
303305
// If using bundle downleveling then there is only one build
304306
// If it fails show any diagnostic messages and bail
305-
if (webpackStats && webpackStats.warnings.length > 0) {
307+
if (statsHasWarnings(webpackStats)) {
306308
context.logger.warn(statsWarningsToString(webpackStats, { colors: true }));
307309
}
308-
if (webpackStats && webpackStats.errors.length > 0) {
310+
if (statsHasErrors(webpackStats)) {
309311
context.logger.error(statsErrorsToString(webpackStats, { colors: true }));
310312
}
311313

@@ -662,14 +664,13 @@ export function buildWebpackBrowser(
662664
break;
663665
default:
664666
assertNever(severity);
665-
break;
666667
}
667668
}
668669

669-
if (webpackStats && webpackStats.warnings.length > 0) {
670+
if (statsHasWarnings(webpackStats)) {
670671
context.logger.warn(statsWarningsToString(webpackStats, { colors: true }));
671672
}
672-
if (webpackStats && webpackStats.errors.length > 0) {
673+
if (statsHasErrors(webpackStats)) {
673674
context.logger.error(statsErrorsToString(webpackStats, { colors: true }));
674675

675676
return { success: false };

0 commit comments

Comments
 (0)
Please sign in to comment.