Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork1.3k
fix(catalogs): preserve existing semver ranges when adding packages with--save-catalog#9762
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Conversation
…ith --save-catalogWhen adding a package with `--save-catalog` to multiple projects in a workspace,the existing catalog entry's semver range (e.g., `^1.0.1`) was being replacedwith a fixed version (e.g., `1.0.1`).This fix checks for existing catalog entries before updating them, ensuring thatcatalog entries maintain their version flexibility across all projects in theworkspace.Fixespnpm#9759
💖 Thanks for opening this pull request! 💖 |
gluxon left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Appreciate the help fixing this!
| if(dep.catalogLookup==null)continue | ||
| updatedCatalogs??={} | ||
| updatedCatalogs[dep.catalogLookup.catalogName]??={} | ||
| updatedCatalogs[dep.catalogLookup.catalogName][dep.alias]=dep.normalizedBareSpecifier??dep.catalogLookup.userSpecifiedBareSpecifier |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This might be fixing the symptom rather than the bug itself. I'd expect thenormalizedBareSpecifier to contain the existing version with a caret. 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Appreciate the heads-up!
I'll dig into it more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
@gluxon
I've fixednpm-resolver to preserve existing semver ranges (e.g.,^1.0.0) inbareSpecifier, ensuringnormalizedBareSpecifier reflects them correctly. Also added support to maintain semver ranges during catalog updates.
zkochan commentedAug 5, 2025
This solution doesn't seem correct but I don't know how to properly do it without digging into it. We should probably check how the specs are preserved during regular "pnpm install" and use the same approach. |
When adding a package with
--save-catalogto multiple projects in a workspace, the existing catalog entry's semver range (e.g.,^1.0.1) was being replaced with a fixed version (e.g.,1.0.1).This fix checks for existing catalog entries before updating them.
Fixes#9759