@gitlab/noop
The idea behind this package is to be able to prune subtrees of dependencies
which you might not need.
Reasons for why you might want to do this:
- Some dependencies (e.g. treesitter) ship a node/server and a browser
component. You might not be interested in the server component, so you could
prune the node/server subtree of dependencies.
- A particular part of dependencies might not be problematic and leading to
oddities. One particular example is the
glob package which ships a CLI
interface which has some ESM-dependencies. One can reduce the dependency
graph by quite a bit
Usage
The different package managers have different resolution features.
npm@v10
overrides
is the native npm feature to override the version of a package. You can target
sub-dependencies:
Example:
{
"overrides": {
"glob": {
"jackspeak": "npm:@gitlab/noop@1.0.0"
}
}
}
yarn@v1
Use
Selective dependency resolutions
and add a resolutions field to the package.json. The resoltions field allows
pretty accurate sub-selection of dependencies.
Example:
{
"resolutions": {
"glob/jackspeak": "npm:@gitlab/noop@1.0.0"
}
}
yarn@v4
You can set the resolution manually with e.g.
yarn set resolution 'jackspeak@npm:^2.3.5' 'npm:@gitlab/noop@1.0.0'
which will only update yarn.lock. Alternatively, you can update the package.json
as well, which is a little more verbose:
Example:
{
"resolutions": {
"jackspeak@npm:^2.3.5": "npm:@gitlab/noop@1.0.0"
}
}
pnpm@v9
pnpm.overrides is the canonical
way to define a resolution for pnpm:
NOTE: With pnpm@9.12.0, you don't need this package. You can simply use -
as an override!
For older versions you can use
this example:
{
"pnpm": {
"overrides": {
"glob>jackspeak": "npm:@gitlab/noop@1.0.0"
}
}
}
bun@v1
Bun supports both npm style overrides
and yarn@1 style resolutions.
Example:
{
"resolutions": {
"jackspeak": "npm:@gitlab/noop@1.0.0"
}
}