What does HackerNews think of rules_nodejs?

JavaScript and NodeJS rules for Bazel

Language: Starlark

#37 in Node.js
Bazel is just the infrastructure to run webpack. You'd need to do some work to make webpack's state be cacheable (I dunno what options and such it has for this, maybe it's already there as an option). But if you're looking at Bazel for JS work you probably just want to use the existing and maintained rules for it: https://github.com/bazelbuild/rules_nodejs It's been a while since I last looked at it but I don't think it has any caching for webpack.
> Is Bazel designed in a way that make it impossible to do JS monorepos well?

Not impossible, but you really need to go all in with it and follow its conventions and practices. See this for the main docs: https://github.com/bazelbuild/rules_nodejs

One thing in particular that doesn't work well in the bazel world is doing your own stuff outside its BUILD.bazel files. If you're used to just npm install and jam some code in your package.json scripts... that doesn't usually work in the bazel world. If you have a lot of logic or tools in your build you'll likely need to go all in and make bazel starlark rules or macros that recreate that logic. Nothing is impossible, but expect to spend time getting up to speed and getting things working the bazel way.

There's some rules here that you can use in bazel. It takes a bit of finesse to get some packages working with it. https://github.com/bazelbuild/rules_nodejs
I started by going through the Java tutorial[1] to get a feel for it. It's fairly approachable and you don't actually need any Java knowledge.

Once you familiarize yourself with the concept of rules and targets, you can follow the instructions for whichever ruleset you want to use. The official one for JS is rules_nodejs[2]

Another thing that really helped me cement my understanding of Bazel was to deep dive into Starlark and write my own rules. The examples repo[3] is a great resource for that

[1] https://docs.bazel.build/versions/0.29.1/tutorial/java.html

[2] https://github.com/bazelbuild/rules_nodejs

[3] https://github.com/bazelbuild/examples/tree/master/rules

Bazel integrates well with nixpkgs and npm with rules_nixpkgs [0] and rules_nodejs [1] respectively.

Tangentially related to package manager integration: Bazel can now build with CMake in-tree [2].

[0] https://github.com/bazelbuild/rules_nixpkgs/

[1] https://github.com/bazelbuild/rules_nodejs/

[2] https://github.com/bazelbuild/rules_foreign_cc/

> By "replacement", I mean picking up a random open source project and being able to do the equivalent of

For that, Bazel needs someone to write all the necessary configs, and make them available out-of-the box, with sane presets baked-in.

You can look at Angular team's working on integrating Bazel into their build process, here's the repo: https://github.com/alexeagle/angular-bazel-example

There's:

- build.bazel

- Workspace

And then there are rules that have to be included and/or developed:

- nodejs rules, https://github.com/bazelbuild/rules_nodejs

- sass rules https://github.com/bazelbuild/rules_sass

- typescript rules: https://github.com/bazelbuild/rules_typescript

etc.

And those rules have to be not only loaded, but specific steps from those rules have to be invoked (see WORKSPACE).

I'd say there still still a lot of configuration involved in setting up all the moving pieces. Will it get better? Hopefully (there are just not enough good/decent build tools).