rushstack
rushstack copied to clipboard
[rush] Customize default installation
Summary
Provide a solution for package maintainers to configure how their project should be installed: as a local package or as an external module. This PR proposes 2 new parameters on rush.json:
- installRemotely: Forces remote installation, even if the package is local (default: false)
- versionRange: Specifies the version range when installing the package (only works if installRemotely = true)
Details
In some cases, developers prefer their dependents to consume their packages using a fixed NPM version, even though the package source is part of the same monorepo. While they continue iterating on their code, they think it is not their responsibility to keep all the dependent projects updated and verified.
rush add will always update the current package.json with "workspace:*" if this module exists in the current workspace. This should be configured by the package maintainer.
rush add -p <package> // always adds dependency { "<package>": "workspace:*" }
Package maintainers should be able to flag their project, as a local or remote project (new parameter: installRemotely). Optionally, it should be possible to explicitly specify the version number, using version range (new parameter: versionRange).
// rush.json
{
...
"projects": [
{
"packageName": "<package>",
"projectFolder": "libs/<package>",
"installRemotely": true,
"versionRange": ">=0.10.3 <15"
},
]
}
"versionRange" will be ignored if the package is locally installed, i.e. "installRemotely" is false.
How it was tested
Tested manually in a local demo repository: https://github.com/pedro-gomes-92/rushstack-playground
Impacted documentation
https://api.rushstack.io/pages/rush-lib.rushconfiguration/#rushconfiguration-class