-
Notifications
You must be signed in to change notification settings - Fork 250
Package overrides #27
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
185c283
Add a package overrides feature.
7af3c00
Formatting
aeschright 89f5d36
Update 0000-package-overrides.md
a57ab28
Adding an additional question to resolve
aeschright e338a70
Switching 'override' for 'replace'
aeschright d312a45
Update 0000-package-overrides.md
zkat ca127d7
Rename 0000-package-overrides.md to 0009-package-overrides.md
zkat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| # Implement a package override option | ||
|
|
||
| ## Summary | ||
|
|
||
| Add a section to package.json that allows the user to designate packages as an 'override' at a particular version. | ||
|
|
||
| ## Motivation | ||
|
|
||
| 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. | ||
|
|
||
| ## Detailed Explanation | ||
|
|
||
| Users will be able to add an additional dependency section called 'overrides' where they give a list of one or more packages to be installed at a specific version. Having this section will ensure that the only version of that package that is eventually installed to the project is the one set as an override. This will not affect the name, source, path, or other aspects of the package's installation. | ||
|
|
||
| ## Rationale and Alternatives | ||
|
|
||
| Users don't frequently need to do this sort of override because npm's nested tree structure allows for a collection of dependencies to require incompatible semvers for the same package. In many cases, the default behavior is acceptable and nothing further is needed. In other, more problematic situations, the user may encounter conflicting binaries or other components that cannot be used simultaneously. The only current options are to attempt to get the maintainers of the dependencies to make changes that will reduce these conflicts, or to use a tool like `https://www.npmjs.com/package/replace-deep-dep` to repair the requirements. | ||
|
|
||
| ## 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?) | ||
|
|
||
| ## Prior Art | ||
|
|
||
| - [Dart](https://www.dartlang.org/tools/pub/dependencies#dependency-overrides) uses a dependency override option that allows defining a specific source or version. | ||
| - [Bower](https://github.com/bower/spec/blob/master/json.md#resolutions) has a setting for 'resolutions', which are package versions to fall back to if there's a conflict. | ||
| - [Yarn](https://yarnpkg.com/en/docs/package-json#toc-resolutions) has a similar resolutions setting, which allows choosing a version or a file source. It allows a more complex system of selecting which packages the override will be applied to. | ||
|
|
||
| Our goal in this RFC is to provide the simplest possible solution to a less common but impactful problem. The most important part of this feature is to define a safe fallback for package versions that conflict. | ||
|
|
||
| ## Unresolved Questions and Bikeshedding | ||
|
|
||
| Are there error situations that could occur? When should the installer exit or warn because the override will not be possible? | ||
|
|
||
| {{THIS SECTION SHOULD BE REMOVED BEFORE RATIFICATION}} | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 installargument - ie, package name/url + @ + version.There was a problem hiding this comment.
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"There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! How soon?
There was a problem hiding this comment.
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