-
-
Notifications
You must be signed in to change notification settings - Fork 151
Description
What is the current behavior?
Currently, rules_js fetches packages from either:
- A remote location (https://registry.nodejs.org/..., git://github.com/...) with the Bazel downloader
- The user workspace (//pkg/left-pad), which requires the package to be pulled into the workspace and its dependencies readable by
npm_translate_lock.
Attempts to link outside the Bazel workspace to an NPM package located elsewhere on-disk get rejected with
invalid link_package outside of the WORKSPACE.
Describe the feature
The npm link workflow is pretty common in the node community, as it allows a dev to modify a third-party package and use it without having to vendor that package.
As a contrived example motivation (replace left-pad with any other package):
- I've found a pathological case in
left-padperformance that my application highlights - I'd like to contribute a fix back to upstream
left-pad. While working on that fix, I want to use the locally-changed copy in my application as a sort of "real world" gut-check in addition to theleft-padtest suite. Just to make sure my pathological case is indeed getting fixed. - I don't want to vendor
left-padfor any number of reasons:left-padhas a complicated/obscure build system that makes it non-trivial to vendor and build withrules_js.left-padtakes bugfixes incredibly fast, so my vendored copy would only exist for a few hours after my PR goes out.
In the current state, there appears to be no way to build left-pad in a separate directory and use it in my rules_js-built package(s).
With vanilla pnpm link (or npm link or β¦), the workflow is roughly:
pnpm --dir ~/bitbucket.org/my-org/my-app link ~/github.com/left-pad/left-padto use a customleft-pad- Change and rebuild
left-pad. - Change and rebuild
my-app. It includes myleft-padchanges.
Ideally, the workflow would be pretty similar under Bazel + rules_js. For local development it feels reasonable to break hermeticity, akin to npm_translate_lock's current use_home_npmrc), but I'd be happy to add an extra flag or two to achieve this.
Relevant slack conversation: https://bazelbuild.slack.com/archives/CEZUUKQ6P/p1689358470077099