[RRFC] Custom Dependency Lists
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 777
- Forks
- 267
- PR merge metrics
- No merged PRs in 30d
Description
Motivation ("The Why")
It is very lacking to separate all dependencies to an unlimited number of lists and, most importantly, to establish dependencies of these lists independently.
This is primarily important for CI / CD. We could shorten work time if you install not all dependencies, but only those necessary for the current task. Now, in order to set dependencies and guarantee the correspondence of their versions and trees use the npm ci command.
Unfortunately, this command downloads absolutely all dependencies. But in many cases some subset needed.
Example
Imagine that we have several workflows:
- Linter.
- Types checking.
- Testing.
- Deploy.
Now, each of these must call npm ci and download a full dependencies tree. But it is obvious that only a subset of this tree is required at each workflow.
How
Current Behaviour
At a time, there is no possibility using npm ci to install a subset of dependencies. For these purposes, you have to use npm install.
Desired Behaviour
It would be possible to allow package.json (or introduce a separate file exclusively for a dependency list) any number of custom lists:
{
"customDependencyLists": {
"lint": {
"eslint": "^0.0.0"
},
"typechecking": {
"typescript": "^0.0.0"
},
"deploy": {
"typescript": "^0.0.0",
"deploy-tools": "^0.0.0"
}
}
}
In the package-lock.json, you can store in each dependence of the lists of lists to which it belongs.
{
"node_modules/typescript": {
"version": "4.2.3",
"resolved": "...",
"integrity": "...",
"dev": true,
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
},
"engines": {
"node": ">=4.2.0"
},
"lists": ["typechecking", "deploy"]
}
}
And add a special parameter to specify which lists of dependencies must be installed:
npm ci --lists=lint
npm ci --lists="lint,typechecking"
References
- Related to https://github.com/npm/npm/issues/10395
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 by reviewing the current npm ci behavior and how package.json and package-lock.json represent dependencies. Evaluate the proposed customDependencyLists structure, list metadata, and --lists option against the lint, typechecking, testing, and deploy examples. Done means the proposal defines a consistent dependency model, lockfile representation, and installation behavior for selected lists.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- build-system, cli, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100