From 884a9d962dadbf8cbe69725741a61eb62077cee1 Mon Sep 17 00:00:00 2001 From: Charles Lyding <19598772+clydin@users.noreply.github.com> Date: Mon, 12 Jan 2026 16:28:24 -0500 Subject: [PATCH 1/2] refactor(@angular/cli): remove resolve dependency and use native require.resolve This commit removes the `resolve` dependency from `@angular/cli` and replaces its usage with native `require.resolve` via `createRequire`. The `findPackageJson` utility is now only used in migration-only scenarios where the Node.js module caching behavior that prompted the original use of `resolve` is no longer a concern. This reduces the package dependency footprint. --- package.json | 1 - packages/angular/cli/BUILD.bazel | 2 -- packages/angular/cli/package.json | 1 - packages/angular/cli/src/utilities/package-tree.ts | 6 +++--- pnpm-lock.yaml | 11 ----------- 5 files changed, 3 insertions(+), 18 deletions(-) diff --git a/package.json b/package.json index ac935c4ead6a..4f136df9262b 100644 --- a/package.json +++ b/package.json @@ -84,7 +84,6 @@ "@types/pacote": "^11.1.3", "@types/picomatch": "^4.0.0", "@types/progress": "^2.0.3", - "@types/resolve": "^1.17.1", "@types/semver": "^7.3.12", "@types/watchpack": "^2.4.4", "@types/yargs": "^17.0.20", diff --git a/packages/angular/cli/BUILD.bazel b/packages/angular/cli/BUILD.bazel index abed616cd810..6d33838ae2e7 100644 --- a/packages/angular/cli/BUILD.bazel +++ b/packages/angular/cli/BUILD.bazel @@ -72,7 +72,6 @@ ts_project( ":node_modules/npm-package-arg", ":node_modules/pacote", ":node_modules/parse5-html-rewriting-stream", - ":node_modules/resolve", ":node_modules/yargs", ":node_modules/zod", "//:node_modules/@angular/core", @@ -80,7 +79,6 @@ ts_project( "//:node_modules/@types/node", "//:node_modules/@types/npm-package-arg", "//:node_modules/@types/pacote", - "//:node_modules/@types/resolve", "//:node_modules/@types/semver", "//:node_modules/@types/yargs", "//:node_modules/@types/yarnpkg__lockfile", diff --git a/packages/angular/cli/package.json b/packages/angular/cli/package.json index 8872ceeee5b0..452594492313 100644 --- a/packages/angular/cli/package.json +++ b/packages/angular/cli/package.json @@ -37,7 +37,6 @@ "npm-package-arg": "13.0.2", "pacote": "21.0.4", "parse5-html-rewriting-stream": "8.0.0", - "resolve": "1.22.11", "semver": "7.7.3", "yargs": "18.0.0", "zod": "4.3.5" diff --git a/packages/angular/cli/src/utilities/package-tree.ts b/packages/angular/cli/src/utilities/package-tree.ts index 14e8a9edd689..3153d8966144 100644 --- a/packages/angular/cli/src/utilities/package-tree.ts +++ b/packages/angular/cli/src/utilities/package-tree.ts @@ -7,8 +7,8 @@ */ import * as fs from 'node:fs'; +import { createRequire } from 'node:module'; import { dirname, join } from 'node:path'; -import * as resolve from 'resolve'; import { NgAddSaveDependency } from './package-metadata'; interface PackageJson { @@ -52,8 +52,8 @@ export async function readPackageJson(packageJsonPath: string): Promise Date: Mon, 12 Jan 2026 16:56:08 -0500 Subject: [PATCH 2/2] refactor(@angular/cli): remove unused package-tree utilities This commit removes the unused `package-tree.ts` utilities, including `getProjectDependencies`, `readPackageJson`, and `PackageTreeNode`. The `findPackageJson` function, which was the only remaining used part, has been moved directly into `commands/update/cli.ts` where it is consumed. --- .../angular/cli/src/commands/update/cli.ts | 12 ++- .../angular/cli/src/utilities/package-tree.ts | 86 ------------------- 2 files changed, 11 insertions(+), 87 deletions(-) delete mode 100644 packages/angular/cli/src/utilities/package-tree.ts diff --git a/packages/angular/cli/src/commands/update/cli.ts b/packages/angular/cli/src/commands/update/cli.ts index b5f0be73539e..8703eb017f24 100644 --- a/packages/angular/cli/src/commands/update/cli.ts +++ b/packages/angular/cli/src/commands/update/cli.ts @@ -29,7 +29,6 @@ import { import { colors } from '../../utilities/color'; import { disableVersionCheck } from '../../utilities/environment-options'; import { assertIsError } from '../../utilities/error'; -import { findPackageJson } from '../../utilities/package-tree'; import { checkCLIVersion, coerceVersionNumber, @@ -697,3 +696,14 @@ async function readPackageManifest(manifestPath: string): Promise; - devDependencies?: Record; - peerDependencies?: Record; - optionalDependencies?: Record; - 'ng-update'?: { - migrations?: string; - }; - 'ng-add'?: { - save?: NgAddSaveDependency; - }; -} - -function getAllDependencies(pkg: PackageJson): Set<[string, string]> { - return new Set([ - ...Object.entries(pkg.dependencies || []), - ...Object.entries(pkg.devDependencies || []), - ...Object.entries(pkg.peerDependencies || []), - ...Object.entries(pkg.optionalDependencies || []), - ]); -} - -export interface PackageTreeNode { - name: string; - version: string; - path: string; - package: PackageJson | undefined; -} - -export async function readPackageJson(packageJsonPath: string): Promise { - try { - return JSON.parse((await fs.promises.readFile(packageJsonPath)).toString()) as PackageJson; - } catch { - return undefined; - } -} - -export function findPackageJson(workspaceDir: string, packageName: string): string | undefined { - try { - const projectRequire = createRequire(join(workspaceDir, 'package.json')); - const packageJsonPath = projectRequire.resolve(`${packageName}/package.json`); - - return packageJsonPath; - } catch { - return undefined; - } -} - -export async function getProjectDependencies(dir: string): Promise> { - const pkg = await readPackageJson(join(dir, 'package.json')); - if (!pkg) { - throw new Error('Could not find package.json'); - } - - const results = new Map(); - for (const [name, version] of getAllDependencies(pkg)) { - const packageJsonPath = findPackageJson(dir, name); - if (!packageJsonPath) { - continue; - } - - results.set(name, { - name, - version, - path: dirname(packageJsonPath), - package: await readPackageJson(packageJsonPath), - }); - } - - return results; -}