refactor(@angular-devkit/build-angular): clean externalMetadata arrays on every rebuild

Currently, externalMetadata arrays get appended the same items over and over again on every rebuild. This commit cleans the array before it appending the new values.
This commit is contained in:
Alan Agius 2023-11-06 11:21:22 +00:00 committed by Alan Agius
parent 988dce6eff
commit ef2437fe95

View File

@ -184,6 +184,11 @@ 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) {
const { implicitBrowser, implicitServer, explicit } = result.externalMetadata;
// Empty Arrays to avoid growing unlimited with every re-build.
externalMetadata.explicit.length = 0;
externalMetadata.implicitServer.length = 0;
externalMetadata.implicitBrowser.length = 0;
externalMetadata.explicit.push(...explicit);
externalMetadata.implicitServer.push(...implicitServer);
externalMetadata.implicitBrowser.push(...implicitBrowser);