CONTRIBUTOR-DOCS / Contributor guides / Patching dependencies
In this doc
Sometimes you may need to temporarily patch a dependency to fix a bug or add functionality while waiting for an upstream fix. This project uses Yarn 4's built-in patching system instead of external tools like patch-package.
-
Extract the package for editing:
yarn patch <package-name>
Example:
yarn patch @web/test-runner-playwright
-
Edit the extracted files in the temporary directory that Yarn creates. Yarn will show you the path where you can make your changes.
-
Commit the patch once you're done editing:
yarn patch-commit -s <temp-folder-path>
Example:
yarn patch-commit -s /private/var/folders/.../user
- Patches are automatically stored in
.yarn/patches/directory - They are applied automatically during
yarn install - Patches are version-specific and will need to be recreated if the dependency version changes
- All patches are committed to the repository so they apply for all contributors
To modify an existing patch:
yarn patch <package-name> --updateThis will extract the current patched version, allowing you to make additional changes.
- Keep patches minimal: Only change what's necessary to fix the specific issue
- Document the reason: Add comments in your pull request explaining why the patch is needed
- Plan for removal: Patches should be temporary until the upstream fix is available
- Test thoroughly: Ensure your patch doesn't break other functionality
For more details, see the Yarn patching documentation.