- Forks considered dangerous
- Method for creating patch files
- Applying the patch
- Recommendation: “patch and PR”
- Clone the dependency locally. If it’s a Bazel module, use
--override_repositoryto point to your local copy without having to change any files in the monorepo. If it’s a library, use whatever mechanism exists in the language’s package manager. For example, pnpm has https://pnpm.io/cli/patch - Make edits like print-debugging in the dependency.
- When you get to a working state, you commit your changes with a good commit message.
- Make a PR to the upstream with your commit (unless it’s confidential internal-only code). Do this even if you don’t really care whether they accept your PR!! This way you’ll share your solution with others, and get comments from the project maintainers that might help you improve your patch or even discover it’s not needed. Furthermore, if the PR is eventually merged, you’ll be able to remove the patch from your repository which lowers your maintenance burden and “complexity budget”.
- Run
git show > /[path/to/monorepo]/[some/bazel]/rule.pr123.patchto make a copy of your commit in the monorepo. You should have some convention for where your Bazel setup belongs, these patches can just go there. By including the PR number in the patch file name, you make it possible for someone browsing the repository to discover the comment thread from upstream maintainers about the patch. - Add the
patch_args=["-p1"]andpatches=["//some/bazel:rule.pr123.patch"]attributes to whatever spot is fetching the dependency.

