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

RFC: No auto-install for peerDependencies marked as optional #224

Closed
wants to merge 2 commits into from
Closed

RFC: No auto-install for peerDependencies marked as optional #224

wants to merge 2 commits into from

Conversation

remyrylan
Copy link
Contributor

Summary

Avoid automatically installing peerDependencies marked as optional using peerDependenciesMeta and { "optional": true }.

Motivation

Package authors want to specify supported version ranges of peerDependencies. They also want to set some peers as optional with peerDependenciesMeta and { "optional": true } to avoid automatically installing them when an end-user installs their package.

As an example, let's take a database ORM package. The ORM package could support upwards of a dozen different databases and require an end-user to install the database adapter(s) needed for their project. These database adapters could be huge and could have peerDependencies, postinstall scripts, and other requirements.

It could significantly bloat a project's install time and dependency tree to pull in tons of packages that an end-developer would never use.

Detailed Explanation

  • When a peer dependency is marked as { "optional": true } using peerDependenciesMeta, it should not install automatically.

  • peerDependencies without a peerDependenciesMeta value of { "optional": true } should still install automatically.

Example package.json

{
  "peerDependencies": {
    "react": "^17.0.0"
  },
  "peerDependenciesMeta": {
    "react": {
      "optional": true
    }
  }
}

References

Related to #221
Fixes #221
Closes #221

@remyrylan
Copy link
Contributor Author

cc/ @arcanis, @zkochan - Are pnpm and Yarn able to follow this implementation? Any objections?

@arcanis
Copy link

arcanis commented Sep 17, 2020

I've been clear that we won't change the peer dependencies default behavior (ie they won't be auto-installed), so in our case this probably won't affect us.

@markcellus
Copy link

markcellus commented Sep 17, 2020

@arcanis yarn won't auto-install peerDeps even after RFC 25 is implemented? I realize this is a little off-topic but is there some other yarn thread where this comment is better suited?

@arcanis
Copy link

arcanis commented Sep 17, 2020

As you can see in #43 and microsoft/types-publisher#655 (comment), I've made it clear that I had significant concerns about RFC 25. I don't think the critical points raised were addressed, and as a result I don't think it would be reasonable to implement it.

@zkochan
Copy link

zkochan commented Sep 17, 2020

I as well wasn't planning to implement #43 in pnpm. If users will demand it, I might consider some solutions. This RFC seems fine

@darcyclarke darcyclarke removed the Agenda will be discussed at the Open RFC call label Sep 18, 2020
@darcyclarke darcyclarke added this to the OSS - Sprint 15 milestone Sep 18, 2020
@darcyclarke darcyclarke self-assigned this Sep 18, 2020
bonkydog added a commit to npm/arborist that referenced this pull request Sep 18, 2020
@ruyadorno
Copy link
Contributor

ooops, we should merge/accept here too, reopening

@ruyadorno ruyadorno reopened this Sep 23, 2020
@remyrylan
Copy link
Contributor Author

remyrylan commented Sep 23, 2020

@ruyadorno I'll remove the ## Unresolved Questions and Bikeshedding section.

Edit: Done!

@ruyadorno ruyadorno closed this in 632557a Sep 23, 2020
@ruyadorno
Copy link
Contributor

Thanks for the contribution @jrylan 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver:major backwards-incompatible breaking changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RRFC] No auto-install for peerDependencies marked as optional
7 participants