Open gonzojive opened 1 year ago
The top-level workflow is just https://pnpm.io/cli/patch - but we should document this, and I think there's also a bit where rules_js needs to know about the patch files that maybe we can make smooth.
Possible that Aspect CLI could have patch
command, which would apply to bazel modules as well (https://github.com/aspect-build/silo/issues/828 for Aspect ppl who can see that repo)
What is the current behavior?
I'm using angular-plotly.js (an npm package) that needs some changes. Making the changes to the dependency is easy (example). There isn't an obvious, canonical process for getting those changes into a project that uses rules_js.
The way I'm doing it is by updating the npm dependency, copying all the patched files into a
third_party/npm/angular-plotly.js
directory, then writing some changesBUILD.bazel
files:The root BUILD.bazel file is just
pnpm-workspace.yaml:
and
package.json
:Some aspects I wish were better about what I did above:
1) There are some apparent differences between the
BUILD.bazel
file generated bynpm_import
and theBUILD.bazel
file one would write if defining a local NPM package. Is that right?bazel-myproj/external/myproj_npm__grpc-web__1.4.2/
uses private rulesI would prefer if I could copy this generated BUILD.bazel file to use as the basis of the patched up dependency.
2) I'm not sure if the change to
package.json
is the right way to do this. I don't personally care about pnpm compatibility as long as the project builds properly with Bazel and the IDE is fully functional. What seems more straightforward to me is adding an "overrides" feature tonpm_link_all_packages
that allows replacing a dependency with some localnpm_package
target that builds the patched-up version of the package. Less to learn for me that way.3) I'd rather store the updated version of the library in a different repository rather than within
third_party/...
- likely a fork of the dependency. I'm not sure how to do this while remaining compatible withpnpm
workspaces.Describe the feature
Document a good way to make changes to an npm dependency.
I like the workflow in rules_go. A set of go_repositories is generated by gazelle. If I want to fix a bug, I'll fork the github project for the dep and update the go_repository rule to point to my fork. Pretty simple, easy to understand, not a lot of boilterplate at all. Can the process be made more like that? There is already some experimental support for gazelle-like behavior by checking in repositories.bzl. Perhaps that could be used, and an override could be made by changing some lines of a
npm_import
call.Fund our work