@gitlab/noop
v1.0.0
Published
This is a noop dependency to be able to prune parts of a dependency graph.
Downloads
47,939
Maintainers
Keywords
Readme
@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:
{
"overrides": {
"glob": {
"jackspeak": "npm:@gitlab/[email protected]"
}
}
}
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.
{
"resolutions": {
"glob/jackspeak": "npm:@gitlab/[email protected]"
}
}
yarn@v4
You can set the resolution manually with e.g.
yarn set resolution 'jackspeak@npm:^2.3.5' 'npm:@gitlab/[email protected]'
which will only update yarn.lock. Alternatively, you can update the package.json as well, which is a little more verbose:
{
"resolutions": {
"jackspeak@npm:^2.3.5": "npm:@gitlab/[email protected]"
}
}
pnpm@v9
pnpm.overrides
is the canonical
way to define a resolution for pnpm:
NOTE: With
[email protected]
, 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/[email protected]"
}
}
}
bun@v1
Bun supports both npm style overrides and yarn@1 style resolutions.
{
"resolutions": {
"jackspeak": "npm:@gitlab/[email protected]"
}
}