Replies: 4 comments 19 replies
-
When you say “optional”, do you mean, specified as such in peerDependenciesMeta? All peer deps are and always have been required by default. |
Beta Was this translation helpful? Give feedback.
-
I do not agree with you. In my opinion, the automatic installation that we were offered brings a few useful things:
|
Beta Was this translation helpful? Give feedback.
-
Came here to add my two cents on this. I can see where @cawa-93 is coming from and the benefits of installing peers by default — however, I also see scenarios where this leads to unexpected behaviours or broken installations; something that a package manager should avoid like the plague. In addition to the We recently upgraded some library to latest
Turns out, This whole ordeal is particularly bizarre because we don't even have a need for Lastly: semantics. I believe they matter. At some point in your argument, you have to acknowledge that introducing something like an |
Beta Was this translation helpful? Give feedback.
-
I am a bit confused as to the current state. Does the latest npm still automatically install optional peers? I see a few links to issues that seem to indicate it was fixed, but then others are saying it's still a problem. Is there an issue tracking it? I couldn't find one so far. |
Beta Was this translation helpful? Give feedback.
-
As of npm 7, peer dependencies are automatically installed without requiring the parent package to depend on them, including for optional peer dependencies. This looks weird to me. Common use cases for optional peer dependencies are:
sass-loader
packages supports using eithersass
ornode-sass
as the sass implementation, and uses optional peer dependencies for that (not defining any peer dependency and relying on package hoisting rules to be able to access the parent package would sometimes work with npm, but would fail with pnpm and yarn 2, and would also sometimes fail with npm depending on how packages were hoisted). this can even lead to surprising results because we end up in the case where the package chooses the implementation based on its rule for the case where multiple peer dependencies are satisfied, even if the project made an explicit choice by installing one of them and not the other.I think it would make sense for optional peer dependencies to not be installed automatically but only validated.
Beta Was this translation helpful? Give feedback.
All reactions