Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make peerDependenciesMeta imply peerDependencies #2128

Closed
sodatea opened this issue Nov 2, 2019 · 1 comment · Fixed by #2143
Assignees
Milestone

Comments

@sodatea
Copy link

@sodatea sodatea commented Nov 2, 2019

The old optional peer dependency proposal is not purely additive. It requires new entries in both peerDependencies and peerDependenciesMeta.
However, for clients that haven't adopted this feature (e.g. the buggy npm cli), new entries in peerDependencies would bring warnings and frighten end users.
So for library authors, adopting this syntax of optional peer dependencies comes at some cost. For me, I'm not willing to do it until npm officially supports this feature in their implementation.

So, as a workaround, Yarn 2 recently implemented a feature to make the new entries in peerDependencies optional: just adding an entry peerDependenciesMeta implies a generic peer dependency (on *).
This makes the syntax fully compatible with old clients. I think it could be a great way to move forward under the current circumstances.

See also at yarnpkg/berry#531

What's the problem this PR addresses?

Some projects are concerned about printing warnings to their users, and prefer not to list their peer dependencies to avoid that. We've solved this a while ago with optional peer dependencies, but the npm registry has a bug that prevents the npm client to leverage this information (Yarn isn't affected). Because of this, the field adoption is lower than it should be, which hurts the JavaScript ecosystem.

How did you fix it?

This diff makes the peerDependenciesMeta field imply a generic peerDependencies (on *). This way, even if the npm installs will still suffer from bogus hoisting (because they'll have no idea about the peer dependencies), at least Yarn won't be hit. And if they fix the bug later down the road, they'll directly benefit from peerDependenciesMeta being more widespread.

@zkochan zkochan added this to the v4.2 milestone Nov 10, 2019
@zkochan zkochan self-assigned this Nov 10, 2019
zkochan added a commit that referenced this issue Nov 10, 2019
close #2128
zkochan added a commit that referenced this issue Nov 10, 2019
close #2128
zkochan added a commit that referenced this issue Nov 10, 2019
close #2128
zkochan added a commit that referenced this issue Nov 10, 2019
close #2128
PR #2143
@zkochan

This comment has been minimized.

Copy link
Member

@zkochan zkochan commented Nov 10, 2019

🚢 4.2.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.