Skip to content

Commit

Permalink
fix(@angular-devkit/build-angular): ensure that externalMetadata is d…
Browse files Browse the repository at this point in the history
…efined

`ng serve` might fail with: `Cannot read properties of undefined (reading 'explicit')` because `result.externalMetadata` is optional.
This commit guards the access and should fix the issue related to the fix 9768c18

(cherry picked from commit 62a7019)
  • Loading branch information
cexbrayat authored and alan-agius4 committed Oct 26, 2023
1 parent 79da8e9 commit c0c7dad
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,13 @@ export async function* serveWithVite(

// To avoid disconnecting the array objects from the option, these arrays need to be mutated
// instead of replaced.
if (result.externalMetadata.explicit) {
externalMetadata.explicit.push(...result.externalMetadata.explicit);
}
if (result.externalMetadata.implicit) {
externalMetadata.implicit.push(...result.externalMetadata.implicit);
if (result.externalMetadata) {
if (result.externalMetadata.explicit) {
externalMetadata.explicit.push(...result.externalMetadata.explicit);
}
if (result.externalMetadata.implicit) {
externalMetadata.implicit.push(...result.externalMetadata.implicit);
}
}

if (server) {
Expand Down

0 comments on commit c0c7dad

Please sign in to comment.