Skip to content

fix(@angular/cli): preserve exact version in ng add when requested#32722

Merged
clydin merged 1 commit intoangular:mainfrom
clydin:cli/add-perf-registry
Mar 9, 2026
Merged

fix(@angular/cli): preserve exact version in ng add when requested#32722
clydin merged 1 commit intoangular:mainfrom
clydin:cli/add-perf-registry

Conversation

@clydin
Copy link
Member

@clydin clydin commented Mar 9, 2026

The ng add command would previously always add a caret (^) prefix to the resolved package version, even if the user explicitly requested an exact version. This change ensures that the exact version is preserved in the package identifier if requested, while maintaining the caret prefix for general requests to ensure consistent behavior with package managers.

@clydin clydin added the target: patch This PR is targeted for the next patch release label Mar 9, 2026
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request aims to preserve exact version specifiers during ng add. The implementation correctly handles cases where an exact version is provided. However, it introduces a regression for specifiers like pkg@*, where an internally resolved version is incorrectly treated as a user-specified exact version, leading to the omission of the ^ prefix. I've provided a detailed comment on the issue and suggested a path for a more robust solution.

The `ng add` command would previously always add a caret (`^`) prefix
to the resolved package version, even if the user explicitly requested
an exact version. This change ensures that the exact version is preserved
in the package identifier if requested, while maintaining the caret
prefix for general requests to ensure consistent behavior with package
managers.
@clydin clydin force-pushed the cli/add-perf-registry branch from 977654a to 853a898 Compare March 9, 2026 13:53
@clydin clydin requested a review from alan-agius4 March 9, 2026 14:11
@clydin clydin added the action: review The PR is still awaiting reviews from at least one requested reviewer label Mar 9, 2026
@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 Mar 9, 2026
@clydin clydin merged commit b5fb457 into angular:main Mar 9, 2026
37 checks passed
@clydin
Copy link
Member Author

clydin commented Mar 9, 2026

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

@clydin clydin deleted the cli/add-perf-registry branch March 9, 2026 15:37
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: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants