mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-20 05:24:57 +08:00
fix(@angular-devkit/build-angular): show child compilation errors
Closes #17565
This commit is contained in:
parent
0e731196e0
commit
64a2686293
@ -94,8 +94,12 @@ export function statsWarningsToString(json: any, statsConfig: any) {
|
|||||||
const colors = statsConfig.colors;
|
const colors = statsConfig.colors;
|
||||||
const rs = (x: string) => colors ? reset(x) : x;
|
const rs = (x: string) => colors ? reset(x) : x;
|
||||||
const y = (x: string) => colors ? bold(yellow(x)) : x;
|
const y = (x: string) => colors ? bold(yellow(x)) : x;
|
||||||
|
const warnings = [...json.warnings];
|
||||||
|
if (json.children) {
|
||||||
|
warnings.push(...json.children.map((c: any) => c.warnings));
|
||||||
|
}
|
||||||
|
|
||||||
return rs('\n' + json.warnings
|
return rs('\n' + warnings
|
||||||
.map((warning: any) => `${warning}`)
|
.map((warning: any) => `${warning}`)
|
||||||
.filter((warning: string) => !ERRONEOUS_WARNINGS.some((erroneous) => erroneous.test(warning)))
|
.filter((warning: string) => !ERRONEOUS_WARNINGS.some((erroneous) => erroneous.test(warning)))
|
||||||
.map((warning: string) => y(`WARNING in ${warning}`))
|
.map((warning: string) => y(`WARNING in ${warning}`))
|
||||||
@ -106,6 +110,18 @@ export function statsErrorsToString(json: any, statsConfig: any) {
|
|||||||
const colors = statsConfig.colors;
|
const colors = statsConfig.colors;
|
||||||
const rs = (x: string) => colors ? reset(x) : x;
|
const rs = (x: string) => colors ? reset(x) : x;
|
||||||
const r = (x: string) => colors ? bold(red(x)) : x;
|
const r = (x: string) => colors ? bold(red(x)) : x;
|
||||||
|
const errors = [...json.errors];
|
||||||
|
if (json.children) {
|
||||||
|
errors.push(...json.children.map((c: any) => c.errors));
|
||||||
|
}
|
||||||
|
|
||||||
return rs('\n' + json.errors.map((error: any) => r(`ERROR in ${error}`)).join('\n'));
|
return rs('\n' + errors.map((error: any) => r(`ERROR in ${error}`)).join('\n'));
|
||||||
|
}
|
||||||
|
|
||||||
|
export function statsHasErrors(json: any): boolean {
|
||||||
|
return json.errors.length > 0 || !!json.children?.some((c: any) => c.errors.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function statsHasWarnings(json: any): boolean {
|
||||||
|
return json.warnings.length > 0 || !!json.children?.some((c: any) => c.warnings.length);
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,8 @@ import {
|
|||||||
generateBuildStats,
|
generateBuildStats,
|
||||||
generateBundleStats,
|
generateBundleStats,
|
||||||
statsErrorsToString,
|
statsErrorsToString,
|
||||||
|
statsHasErrors,
|
||||||
|
statsHasWarnings,
|
||||||
statsToString,
|
statsToString,
|
||||||
statsWarningsToString,
|
statsWarningsToString,
|
||||||
} from '../angular-cli-files/utilities/stats';
|
} from '../angular-cli-files/utilities/stats';
|
||||||
@ -302,10 +304,10 @@ export function buildWebpackBrowser(
|
|||||||
if (!success && useBundleDownleveling) {
|
if (!success && useBundleDownleveling) {
|
||||||
// If using bundle downleveling then there is only one build
|
// If using bundle downleveling then there is only one build
|
||||||
// If it fails show any diagnostic messages and bail
|
// If it fails show any diagnostic messages and bail
|
||||||
if (webpackStats && webpackStats.warnings.length > 0) {
|
if (statsHasWarnings(webpackStats)) {
|
||||||
context.logger.warn(statsWarningsToString(webpackStats, { colors: true }));
|
context.logger.warn(statsWarningsToString(webpackStats, { colors: true }));
|
||||||
}
|
}
|
||||||
if (webpackStats && webpackStats.errors.length > 0) {
|
if (statsHasErrors(webpackStats)) {
|
||||||
context.logger.error(statsErrorsToString(webpackStats, { colors: true }));
|
context.logger.error(statsErrorsToString(webpackStats, { colors: true }));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -662,14 +664,13 @@ export function buildWebpackBrowser(
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
assertNever(severity);
|
assertNever(severity);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (webpackStats && webpackStats.warnings.length > 0) {
|
if (statsHasWarnings(webpackStats)) {
|
||||||
context.logger.warn(statsWarningsToString(webpackStats, { colors: true }));
|
context.logger.warn(statsWarningsToString(webpackStats, { colors: true }));
|
||||||
}
|
}
|
||||||
if (webpackStats && webpackStats.errors.length > 0) {
|
if (statsHasErrors(webpackStats)) {
|
||||||
context.logger.error(statsErrorsToString(webpackStats, { colors: true }));
|
context.logger.error(statsErrorsToString(webpackStats, { colors: true }));
|
||||||
|
|
||||||
return { success: false };
|
return { success: false };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user