Skip to content

Commit 5e47d82

Browse files
committed
refactor(@angular-devkit/build-angular): show build time on failures with application builder
The build time is now shown when bundling fails. Previously only the errors were shown. This provides additional information that the build did indeed fail and how long it took to fail.
1 parent 0862a38 commit 5e47d82

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

packages/angular_devkit/build_angular/src/builders/application/execute-build.ts

-5
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ export async function executeBuild(
4141
context: BuilderContext,
4242
rebuildState?: RebuildState,
4343
): Promise<ExecutionResult> {
44-
const startTime = process.hrtime.bigint();
45-
4644
const {
4745
projectRoot,
4846
workspaceRoot,
@@ -251,11 +249,8 @@ export async function executeBuild(
251249
}
252250

253251
printWarningsAndErrorsToConsole(context, warnings, errors);
254-
255252
logBuildStats(context, metafile, initialFiles, budgetFailures, estimatedTransferSizes);
256253

257-
const buildTime = Number(process.hrtime.bigint() - startTime) / 10 ** 9;
258-
context.logger.info(`Application bundle generation complete. [${buildTime.toFixed(3)} seconds]`);
259254
// Write metafile if stats option is enabled
260255
if (options.stats) {
261256
executionResult.addOutputFile(

packages/angular_devkit/build_angular/src/builders/application/index.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,19 @@ export async function* buildApplicationInternal(
4949
const normalizedOptions = await normalizeOptions(context, projectName, options, plugins);
5050

5151
yield* runEsBuildBuildAction(
52-
(rebuildState) => executeBuild(normalizedOptions, context, rebuildState),
52+
async (rebuildState) => {
53+
const startTime = process.hrtime.bigint();
54+
55+
const result = await executeBuild(normalizedOptions, context, rebuildState);
56+
57+
const buildTime = Number(process.hrtime.bigint() - startTime) / 10 ** 9;
58+
const status = result.errors.length > 0 ? 'failed' : 'complete';
59+
context.logger.info(
60+
`Application bundle generation ${status}. [${buildTime.toFixed(3)} seconds]`,
61+
);
62+
63+
return result;
64+
},
5365
{
5466
watch: normalizedOptions.watch,
5567
poll: normalizedOptions.poll,

0 commit comments

Comments
 (0)