-
Notifications
You must be signed in to change notification settings - Fork 522
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
RFC: npm_fetch_packages rule #2121
Comments
https://www.npmjs.com/package/@yarnpkg/lockfile maybe useful to ask yarn for the manifest of tarballs and SHAs that Bazel should fetch |
@alexeagle I think this is a great idea. I can see it being a big improvement for large monorepos like ours with one package.json at the top-level. |
This is definitely seems more bazel-idiomatic, and overall an improvement. I think if we continue to maintain the current method as well that significantly decreases how much we would need to be concerned about the downsides, though if maintaining two became a problem then I would prefer this |
With regards to maintainership, I wonder if the current method should even be maintained (long term) as it introduces the following issues:
Moving to a world like the proposed in the issue will probably make supporting yarn/npm workspaces "free" and solve #399, while the current behavior negates most benefits from using Bazel. |
The current method has to be maintained long-term unless we provide a migration path that's relatively easy and accessible to everyone. It's wise to avoid load'ing from any external repo you don't want to fetch - so maybe reorganizing the sources a bit allows you to avoid the undesirable load statement (e.g. make a "js" subdirectory and don't request targets in there) |
I decided to work on this in a fresh repo, as rules_nodejs is getting too hard to maintain. See aspect-build/rules_js |
In other modern Bazel rulesets (commonly called the "external" model like https://github.com/dillon-giacoppo/rules_python_external), the dependency story is roughly:
requirements.txt
npm install
on each package individually)deps
(possibly with some syntax sugar so they all come from oneload
like therequirements()
helper in rules_python_externalWe could do this for rules_nodejs, I'll call this proposed repository rule
npm_fetch_packages()
for the sake of discussion.For npm, this has tradeoffs.
Downsides:
node_modules
, but then programs that require multiple versions of the same library (pretty common) will stop working. We could always nest.Upsides:
npm install
oryarn install
a whole monorepo package.json file even if you only needtypescript
to type-check, for example.The text was updated successfully, but these errors were encountered: