Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: clarify usage of patch-package for patching local npm dependencies #2529

Merged
merged 1 commit into from
Mar 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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