Skip to content

Commit

Permalink
docs: overrides remove packages
Browse files Browse the repository at this point in the history
  • Loading branch information
KSXGitHub committed Oct 3, 2024
1 parent bdcda23 commit c8d6033
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions docs/package_json.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ For example:

This field allows you to instruct pnpm to override any dependency in the
dependency graph. This is useful to enforce all your packages to use a single
version of a dependency, backport a fix, or replace a dependency with a fork.
version of a dependency, backport a fix, replace a dependency with a fork, or
removing an unused dependency.

Note that the overrides field can only be set at the root of the project.

Expand All @@ -246,7 +247,7 @@ An example of the `"pnpm"."overrides"` field:
}
```

You may specify the package the overriden dependency belongs to by
You may specify the package the overridden dependency belongs to by
separating the package selector from the dependency selector with a ">", for
example `qar@1>zoo` will only override the `zoo` dependency of `qar@1`, not for
any other dependencies.
Expand Down Expand Up @@ -282,6 +283,20 @@ The referenced package does not need to match the overridden one:
}
```

If you find that your use of a certain package doesn't require one of its dependency,
you may use `-` to remove them. For example, package `[email protected]` requires a big package
named `bar` for a function that you don't use, removing it could reduce install time:

```json
{
"pnpm": {
"overrides": {
"[email protected]>bar": "-"
}
}
}
```

## pnpm.packageExtensions

The `packageExtensions` fields offer a way to extend the existing package definitions with additional information. For example, if `react-redux` should have `react-dom` in its `peerDependencies` but it has not, it is possible to patch `react-redux` using `packageExtensions`:
Expand Down Expand Up @@ -685,4 +700,3 @@ Functionally identical to [`pnpm.overrides`], this field is intended to make it

[pnpm patch-commit]: ./cli/patch-commit.md
[`pnpm.overrides`]: #pnpmoverrides

0 comments on commit c8d6033

Please sign in to comment.