-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Support optional peerDependencies #6487
Comments
Thanks @edmorley for picking this up, it would be great to have a feature like this. (Also, regardless of PnP, it would provide a way to express "I don't need this package, but when present it has to be version range XYZ"). I was actually thinking Just thinking out loud, I don't really have the full picture of all the implications with regard to backward compatibility and compat with other package managers. |
Regarding Regarding Another option, maybe more radical, is to make the value type of {
"peerDependencies": {
"html-webpack-plugin": {
"range": "^x.y.z",
"optional": true
}
}
} |
I'm not arguing against your approach at all, looks great. But just to clarify, what I was suggesting would be backward compatible not just by chance and would compose well. It would look something like this:
(Edited to rename |
Oh I see, sorry! Yep, would work indeed. |
What about optional dev dependencies though? Not to blow up the scope of this ticket, but since you mentioned composability - I remember wanting for that feature once. |
Things like optional dev dependencies require a relatively huge investment since we would have to support a "better dependencies" field that would allow meta information to be passed to the package manager on top of the range (or doubling down to the antipattern that are fields such as Considering the pros/cons, I think adding a syntax to the
Note that |
I was wondering why this problem hasn't come up with So if we add a new field for It would be nice to support other types of optional dependencies as well, especially given that these were possible prior to PnP but won't work with it. It is definitely a more difficult problem to solve, and probably outside the scope of this issue. But I think having a long-term goal in mind for other optional dependencies would be helpful in deciding which path to take on optional peer dependencies in the short term. This discussion should be moved to an RFC. This change is definitely significant enough to warrant one. |
Last time I heard about tink they weren't actually getting rid of the node_modules, just virtualizing it. It still exists, but not on the filesystem (basically doing the same thing than a FUSE filesystem would do, except that they trade the ability to run any tool for an increased portability). It's really quite different from the PnP goals (for example they can't make the guarantees we give regarding how packages are instanciated or optimized, because they're still limited by the fs hierarchy). Compare us with pnpm rather than tink, they're much closer to PnP than tink.
Yep, it's much more complex - I prefer to first have a short-term plan for optional peer dependencies, and only then think about an overhaul of how dependencies are setup (which would take at least a year before being drafted, let alone implemented and deployed).
Will submit an RFC early next week (based on the |
yarnpkg/rfcs#105 Has been merged and it is implemented in yarn 1.13. Can this be marked as closed now? (also, @arcanis should the RFC be moved to the |
It looks like the latest versions of Yarn got rid of the |
It never got implemented as the |
Good. I like the |
Do you want to request a feature or report a bug?
Feature
What is the current behavior?
With Yarn's new Plug and Play feature, if a package uses another package, it must include that other package either in
dependencies
orpeerDependencies
otherwise there will be a runtime resolution failure.However some projects intentionally omit the dependency if it's for an optional feature. For example in:
waysact/webpack-subresource-integrity#90
At the moment such projects have a choice between:
What is the expected behavior?
To have a (backwards-compatible) way to declare a peer dependency as optional, which would allow the PnP resolver to still work, but if the optional peer dep package was not installed, there would not be a "missing peer dependency" warning shown during yarn install.
In waysact/webpack-subresource-integrity#90 (comment) this form was proposed:
And in waysact/webpack-subresource-integrity#90 (comment), this:
Please mention your node.js, yarn and operating system version.
Yarn 1.12.0, all OSes.
CC @arcanis, @jscheid
The text was updated successfully, but these errors were encountered: