-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Contribution
- I'd be willing to implement this feature (contributing guide)
Describe the user story
When running pnpm add
, pnpm currently adds the latest version with of that dependency with ^
. For example, running pnpm add is-positive
edits package.json
with the following contents:
{
"name": "@example/lib",
"dependencies": {
"is-positive": "^3.1.0"
}
}
Describe the solution you'd like
When a user has set up a default catalog entry for a dependency, it's likely that new usages of this dependency in a workspace package are intended to use the catalog protocol. Instead of adding a new version, use the catalog protocol:
{
"name": "@example/lib",
"dependencies": {
"is-positive": "catalog:"
}
}
Related: I realized we don't do this for workspace packages at the moment. It likely makes sense to add workspace:*
out of the box too. (#6770)
Describe the drawbacks of your solution
Some users may prefer not using the catalog protocol out of the box, but I expect this to be exceedingly rare and somewhat defeats the purpose of catalogs.
There's a few more ambiguous cases with named catalogs though:
- When a user has a dependency to a named catalog, should we use that?
- When a user has a dependency in multiple named catalogs, which one should be added?
- When a user has a default catalog and one more more named catalogs, does it still make sense to use the default catalog?
We can probably start by simply using the default catalog on pnpm add
and ignoring named catalogs, but perhaps a future version prompts users if there's multiple named catalogs.