Skip to content

Commit c0c7dad

Browse files
cexbrayatalan-agius4
authored andcommitted
fix(@angular-devkit/build-angular): ensure that externalMetadata is defined
`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)
1 parent 79da8e9 commit c0c7dad

File tree

1 file changed

+7
-5
lines changed
  • packages/angular_devkit/build_angular/src/builders/dev-server

1 file changed

+7
-5
lines changed

packages/angular_devkit/build_angular/src/builders/dev-server/vite-server.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,13 @@ export async function* serveWithVite(
172172

173173
// To avoid disconnecting the array objects from the option, these arrays need to be mutated
174174
// instead of replaced.
175-
if (result.externalMetadata.explicit) {
176-
externalMetadata.explicit.push(...result.externalMetadata.explicit);
177-
}
178-
if (result.externalMetadata.implicit) {
179-
externalMetadata.implicit.push(...result.externalMetadata.implicit);
175+
if (result.externalMetadata) {
176+
if (result.externalMetadata.explicit) {
177+
externalMetadata.explicit.push(...result.externalMetadata.explicit);
178+
}
179+
if (result.externalMetadata.implicit) {
180+
externalMetadata.implicit.push(...result.externalMetadata.implicit);
181+
}
180182
}
181183

182184
if (server) {

0 commit comments

Comments
 (0)