berry icon indicating copy to clipboard operation
berry copied to clipboard

Add support for catalog references in peer dependencies

Open WooWan opened this issue 4 months ago • 6 comments

What's the problem this PR addresses?

Fixes: https://github.com/yarnpkg/berry/issues/6925

Adds support for catalog: protocol in peerDependencies. Previously, catalog references in peer dependencies were incorrectly reported. This change allows catalog references to be used in peer dependencies, consistent with their support in other dependency types.

...

How did you fix it?

Updated the dependency range validation logic in Manifest.ts to treat catalog: protocol as a valid range format. This prevents catalog references from being flagged as errors when used in peer dependencies.

...

Checklist

  • [x] I have set the packages that need to be released for my changes to be effective.
  • [x] I will check that all automated PR checks pass before the PR gets reviewed.

WooWan avatar Sep 27 '25 09:09 WooWan

Hi, any update on this one would be nice to use also catalog references inside the peerDeps. 🙏🏻

MKruschke avatar Nov 03 '25 10:11 MKruschke

I'm not certain that's correct - afaik the reduceDependency hook we use to apply catalog updates doesn't iterate over peerDependencies, so we'd always keep the catalog: range in the peerDependencies field rather than replacing it.

arcanis avatar Nov 07 '25 06:11 arcanis

I'm not certain that's correct - afaik the reduceDependency hook we use to apply catalog updates doesn't iterate over peerDependencies, so we'd always keep the catalog: range in the peerDependencies field rather than replacing it.

I'm not very familiar with reduceDependency, do you think the fundamental solution would be to fix reduceDependency so that it iterates over peerDependencies as well?

WooWan avatar Nov 07 '25 07:11 WooWan

That would be a breaking change, as 3rd-party plugins would have their behavior changed in hard-to-predict ways.

Probably the safest is to introduce a reducePeerDependency hook here and here. I'm a little worried about the potential perf impact but it's worth a shot.

arcanis avatar Nov 07 '25 08:11 arcanis

Hey, still looking forward to get catalog ranges enabled for peerDependencies. @WooWan please let me know if you can finished it otherwise I would offer some help.

MKruschke avatar Dec 09 '25 16:12 MKruschke

I've been busy and haven't been able to get to the PR. I'll work on it by next weekend! @MKruschke

WooWan avatar Dec 09 '25 16:12 WooWan