Skip to content

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

@RemyRylan

Description

@RemyRylan

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions