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

[RRFC] No auto-install for peerDependencies marked as optional #221

Closed
remyrylan opened this issue Sep 8, 2020 · 1 comment
Closed

[RRFC] No auto-install for peerDependencies marked as optional #221

remyrylan opened this issue Sep 8, 2020 · 1 comment
Assignees

Comments

@remyrylan
Copy link
Contributor

Motivation ("The Why")

As a package author, I want to specify supported version ranges of peerDependencies. I also want to set some peers as optional with peerDependenciesMeta and { "optional": true } to avoid automatically installing them when an end-user installs a package I've authored.

Example

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 even use.

How

Current Behaviour

npm v7 currently installs all peerDependencies, regardless if set as optional or not using peerDependenciesMeta.

Desired Behaviour

Personally, it seems ideal to me to not auto-install peerDependencies marked as optional. I believe it would be a massive benefit to the package ecosystem.

peerDependencies not marked as optional should still install automatically.

References

  • n/a
@remyrylan remyrylan changed the title [RRFC] Do not auto-install peerDependencies marked as optional. [RRFC] Do not auto-install peerDependencies marked as optional Sep 8, 2020
@remyrylan remyrylan changed the title [RRFC] Do not auto-install peerDependencies marked as optional [RRFC] No auto-install for peerDependencies marked as optional Sep 8, 2020
@darcyclarke darcyclarke added the Agenda will be discussed at the Open RFC call label Sep 9, 2020
@darcyclarke darcyclarke removed the Agenda will be discussed at the Open RFC call label Sep 18, 2020
@darcyclarke darcyclarke self-assigned this Sep 18, 2020
@remyrylan
Copy link
Contributor Author

This has been implemented here: npm/arborist@e13ba3b

The final decision was to go with treating { "optional": true } as the trigger to disable auto install of a peer dependency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants