You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Our desired deduplication strategy is for dependencies to use the "primary" version when possible (the one specified in package.json), rather than highest or fewer.
Problem
When using highest, when packages have loosely specified dependencies, introducing a new version into the tree (but not as the "primary") causes these packages to get upgraded to the newest version. This is not always desired, and can cause version mismatch issues.
For example, many packages allow @types/node: * or similarly loose versions. We specify a version of @types/node that ~aligns with the version of node we are using. But when we install/upgrade a package that asks for a higher version of @types/node, yarn-deduplicate then forces most of our other packages to use this new version, which is not what we want. At the moment, we get around this by excluding @types/node, but this is not ideal because we do want to deduplicate it.
Possible Solutions
A new option called --preferPrimary or something like that. This would add a new rule that prefers the primary version where possible, and otherwise falls back to the --strategy.
Similar, but implement as --strategy=primary. However, this might be a bit unclear as to what if falls back to, and not as flexible.
I'd be happy to try to draft a PR if maintainers are open to it!
The text was updated successfully, but these errors were encountered:
joshkaplan
changed the title
Strategy that uses "primary" version (specified in package.json) as much as possible
Strategy that prefers "primary" version (specified in package.json)
Dec 8, 2023
Our desired deduplication strategy is for dependencies to use the "primary" version when possible (the one specified in package.json), rather than
highest
orfewer
.Problem
When using
highest
, when packages have loosely specified dependencies, introducing a new version into the tree (but not as the "primary") causes these packages to get upgraded to the newest version. This is not always desired, and can cause version mismatch issues.For example, many packages allow
@types/node: *
or similarly loose versions. We specify a version of@types/node
that ~aligns with the version ofnode
we are using. But when we install/upgrade a package that asks for a higher version of@types/node
,yarn-deduplicate
then forces most of our other packages to use this new version, which is not what we want. At the moment, we get around this by excluding@types/node
, but this is not ideal because we do want to deduplicate it.Possible Solutions
--preferPrimary
or something like that. This would add a new rule that prefers the primary version where possible, and otherwise falls back to the--strategy
.--strategy=primary
. However, this might be a bit unclear as to what if falls back to, and not as flexible.I'd be happy to try to draft a PR if maintainers are open to it!
The text was updated successfully, but these errors were encountered: