Skip to content

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

Merged
clydin merged 1 commit into
angular: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 into
angular:mainfrom
clydin:cli/add-perf-registry

Conversation

@clydin

@clydin clydin commented Mar 9, 2026

Copy link
Copy Markdown
Member

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

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

Copy link
Copy Markdown

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.

Comment thread packages/angular/cli/src/commands/add/cli.ts Outdated
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

clydin commented Mar 9, 2026

Copy link
Copy Markdown
Member Author

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
@angular-automatic-lock-bot

Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Apr 9, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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