Skip to content

Conversation

@clydin
Copy link
Member

@clydin clydin commented Jan 12, 2026

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.

…ire.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.
@clydin clydin added the target: minor This PR is targeted for the next minor release label Jan 12, 2026
@clydin clydin added the action: review The PR is still awaiting reviews from at least one requested reviewer label Jan 12, 2026
@clydin clydin requested a review from alan-agius4 January 12, 2026 21:52
@clydin clydin marked this pull request as ready for review January 12, 2026 21:53
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.
function findPackageJson(workspaceDir: string, packageName: string): string | undefined {
try {
const projectRequire = createRequire(path.join(workspaceDir, 'package.json'));
const packageJsonPath = projectRequire.resolve(`${packageName}/package.json`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a small gotcha for this which is that exports fields can mess with resolving package.json. But 99.9% of the time, an Angular app shouldn't have an exports field (and 90% of the remaining time, people should've added package.json to their exports).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Packages that contain Angular migrations must have a resolvable package.json so in this specific usage we can luckily avoid that situation.

@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Jan 13, 2026
@clydin clydin merged commit e6b62a1 into angular:main Jan 13, 2026
35 checks passed
@clydin
Copy link
Member Author

clydin commented Jan 13, 2026

This PR was merged into the repository. The changes were merged into the following branches:

@clydin clydin deleted the cli/no-update-resolve branch January 13, 2026 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: @angular/cli target: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants