Skip to content

Commit 8f440b4

Browse files
authored
docs: clarify usage of patch-package for patching local npm dependencies (#2529)
1 parent 9d0ec93 commit 8f440b4

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

docs/changing-rules.html

Lines changed: 8 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/changing-rules.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,14 @@ If you have a small change, it's easiest to just patch the distributed artifacts
1616

1717
## Patching the npm packages
1818

19-
The pattern we use most commonly is to add a `postinstall` hook to your `package.json` that patches files after they've been fetched from npm.
19+
The pattern we use most commonly is to use [patch-package]. To store your local changes to the npm packages follow the steps:
2020

21-
See `/tools/postinstall-patches.js` in the [Angular repo] for an example.
21+
1. `npm i -D patch-package`
22+
1. Edit the target package in your `node_modules`
23+
1. Run `npx patch-package <npm package>`. This will store the patch in the `patches/` directory in the root of the workspace
24+
1. Add `"postinstall": "patch-package"` to the `package.json` in your repo to apply the patches when building dependencies (aka at `npm install`)
2225

23-
[Angular repo]: https://github.com/angular/angular/tree/master/tools/postinstall-patches.js
26+
[patch-package]: https://www.npmjs.com/package/patch-package
2427

2528
## Patching the built-in release
2629

0 commit comments

Comments
 (0)