From 4eea6a6ca8ba6809f39cbf8583964ed8ed3e69ae Mon Sep 17 00:00:00 2001 From: Charles Lyding <19598772+clydin@users.noreply.github.com> Date: Thu, 11 Dec 2025 12:30:31 -0500 Subject: [PATCH] perf(@angular/cli): cache resolved specific version in package manager abstraction When fetching a package manifest for a tag or range, also cache the result using the resolved specific version. This avoids redundant lookups if the specific version is requested subsequently. Also removes an unused import. --- .../cli/src/package-managers/package-manager.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/angular/cli/src/package-managers/package-manager.ts b/packages/angular/cli/src/package-managers/package-manager.ts index 7a012a3e544c..b76831be109c 100644 --- a/packages/angular/cli/src/package-managers/package-manager.ts +++ b/packages/angular/cli/src/package-managers/package-manager.ts @@ -15,7 +15,7 @@ import { join } from 'node:path'; import npa from 'npm-package-arg'; import { maxSatisfying } from 'semver'; -import { ErrorInfo, PackageManagerError } from './error'; +import { PackageManagerError } from './error'; import { Host } from './host'; import { Logger } from './logger'; import { PackageManagerDescriptor } from './package-manager-descriptor'; @@ -407,11 +407,22 @@ export class PackageManager { const cacheKey = options.registry ? `${specifier}|${options.registry}` : specifier; - return this.#fetchAndParse( + const manifest = await this.#fetchAndParse( commandArgs, (stdout, logger) => this.descriptor.outputParsers.getRegistryManifest(stdout, logger), { ...options, cache: this.#manifestCache, cacheKey }, ); + + // If the provided version was not a specific version, also cache the specific fetched version + if (manifest && manifest.version !== version) { + const manifestSpecifier = `${manifest.name}@${manifest.version}`; + const manifestCacheKey = options.registry + ? `${manifestSpecifier}|${options.registry}` + : manifestSpecifier; + this.#manifestCache.set(manifestCacheKey, manifest); + } + + return manifest; } /**