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] Accepting version references within dependencies and devDependencies #677

Open
mon-jai opened this issue Feb 17, 2023 · 0 comments
Open

Comments

@mon-jai
Copy link

mon-jai commented Feb 17, 2023

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
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

No branches or pull requests

1 participant