[RRFC] Accepting version references within `dependencies` and `devDependencies`
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 778
- Forks
- 266
- PR merge metrics
- No merged PRs in 30d
Description
Motivation ("The Why")
There are some use cases where you need to switch dependencies' to a different version (e.g. downgrading/switching to beta version, etc.). But by doing so, you maybe end up with wrong version of typings (@type/*) or incompatible version of other packages (such as Babel).
Version references are already valid within the overrides field:
{
"dependencies": {
"foo": "^1.0.0"
},
"overrides": {
// BEST, the override is defined as a reference to the dependency
"foo": "$foo",
// the referenced package does not need to match the overridden one
"bar": "$foo"
}
}
It would be nice if we also accept them in dependencies and devDependencies, making it seamlessly to update dependencies' version, without risking to break something unintended.
Example
Usage with Babel:
{
"devDependencies": {
"@babel/cli": "^7.0.0",
- "@babel/core": "^7.0.0"
+ "@babel/core": "$@babel/cli"
}
}
Usage with types:
{
"dependencies": {
"react-native": "^0.70.5",
},
"devDependencies": {
- "@types/react-native": "^0.70.5"
+ "@types/react-native": "$react-native"
}
}
How
Current Behaviour
npm update @babel/cli
{
"devDependencies": {
"@babel/cli": "^7.20.7",
"@babel/core": "^7.0.0" // Not updated
}
}
npm update react-native
{
"dependencies": {
"react-native": "^0.71.3",
},
"devDependencies": {
"@types/react-native": "^0.70.5" // Wrong version
}
}
References
- n/a
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the RFC examples for dependencies, devDependencies, and overrides, then clarify how referenced package versions should be resolved during npm update. Done would mean an accepted design covering the Babel and React Native cases and the compatibility implications.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100