Skip to content

Commit

Permalink
docs: clarify usage of patch-package for patching local npm dependenc…
Browse files Browse the repository at this point in the history
…ies (#2529)
  • Loading branch information
parabolala authored Mar 14, 2021
1 parent 9d0ec93 commit 8f440b4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
11 changes: 8 additions & 3 deletions docs/changing-rules.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions docs/changing-rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ If you have a small change, it's easiest to just patch the distributed artifacts

## Patching the npm packages

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.
The pattern we use most commonly is to use [patch-package]. To store your local changes to the npm packages follow the steps:

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

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

## Patching the built-in release

Expand Down

0 comments on commit 8f440b4

Please sign in to comment.