fix(@angular/build): always clear dev-server error overlay on non-error result

Now that additional result object types can be returned from the build
system, the error overlay must be cleared on all non-error results. The
introduction of component update results and eventual incremental results
will now properly clear the error overlay after a successful build.
This commit is contained in:
Charles Lyding 2024-11-04 20:21:09 -05:00 committed by Alan Agius
parent 71b3de8364
commit 99192a791b

View File

@ -187,8 +187,7 @@ export async function* serveWithVite(
// TODO: Switch this to an architect schedule call when infrastructure settings are supported
for await (const result of builderAction(browserOptions, context, extensions?.buildPlugins)) {
switch (result.kind) {
case ResultKind.Failure:
if (result.kind === ResultKind.Failure) {
if (result.errors.length && server) {
hadError = true;
server.ws.send({
@ -201,6 +200,18 @@ export async function* serveWithVite(
});
}
continue;
}
// Clear existing error overlay on successful result
if (hadError && server) {
hadError = false;
// Send an empty update to clear the error overlay
server.ws.send({
'type': 'update',
updates: [],
});
}
switch (result.kind) {
case ResultKind.Full:
if (result.detail?.['htmlIndexPath']) {
htmlIndexPath = result.detail['htmlIndexPath'] as string;
@ -253,16 +264,6 @@ export async function* serveWithVite(
continue;
}
// Clear existing error overlay on successful result
if (hadError && server) {
hadError = false;
// Send an empty update to clear the error overlay
server.ws.send({
'type': 'update',
updates: [],
});
}
// To avoid disconnecting the array objects from the option, these arrays need to be mutated instead of replaced.
let requiresServerRestart = false;
if (result.detail?.['externalMetadata']) {