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

Package overrides #27

Merged
merged 7 commits into from
Jan 10, 2019
Merged

Package overrides #27

merged 7 commits into from
Jan 10, 2019

Conversation

aeschright
Copy link
Contributor

No description provided.


## Implementation

In order to do this, the npm installer will need to read in an overrides section from `package.json`. This will have a simple format such as `overrides: { 'foo': '1.2.3' }`. These values will need to be used at the end of the tree-building process to select the final version. (Is there also a pruning element to this?)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if i want to override one package with another - like underscore for lodash, etc?

It would be ideal if the RHS of this could also be a full npm install argument - ie, package name/url + @ + version.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You would use package aliases, which are coming soon, so: "undescore": "npm:lodash"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! How soon?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the same soon as overrides

@markcellus
Copy link

markcellus commented Dec 21, 2018

In some situations, allowing more than one version of a package to be installed at the same time can cause unwanted behaviors. This will allow users to fix that by explicitly setting a single version to use.

Wouldn't locking the dep at a certain version and running npm depupe with a package-lock.json file work for these cases?

This proposal seems similar to the resolutions field that yarn uses when having to manually resolve dependencies, which I've used. But I've found that, in practice ,these types of overrides can become easily forgotten about since it gives us another thing to manage.

But a bigger concern I have is that this seems like a solution for a symptom of the problem but doesn't attack the real problem. The real problem is that there's currently no reliable way for package maintainers to actually mark that their package should only have a single version in a consumer's dep tree. Once that is solved, I think npm can enforce it when a consumer attempts to install it and give the consumer an option on how to handle the mismatched versions, using npm dedupe or similar.

@zkat
Copy link
Contributor

zkat commented Jan 10, 2019

@mkay581 Overrides is solving a different problem! We do have a Singleton Package RFC for the "larger" problem you mention -- but overrides can be used for things like updating deep dependencies with security-patched forks, or different versions with important patches (or preventing a semver update from updating to a broken version). These are some of the examples, but ultimately, this is orthogonal to singletons, which will benefit from this, but this is not the primary purpose at all.

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 this pull request may close these issues.

4 participants