davidalucas / aoc-2023

Advent of Code 2023 (Polyglot)
MIT License
0 stars 0 forks source link

Add support for JavaScript #1

Open davidalucas opened 8 months ago

davidalucas commented 8 months ago

To get started, let's get JavaScript set up and running in this repo. I'm going to borrow some code from my aoc-2023-js repo (so that I have some working code and tests), but I'm not going to bring over the whole code base. I want to get some experience on what the workflow feels like when you're working in a monorepo with Bazel.

davidalucas commented 8 months ago

Well, the first step to solving this problem is going to be to get Bazel installed on our system. As with any project, whenever you find that you're having to install something onto your local system, you're going to want to add the installation instructions to the project README, so I'm going to add a checkbox to make sure I don't forget that...

davidalucas commented 8 months ago

Ooook... So this is turning out to be WAY worse than I thought it would be. Bazel doesn't support Node.js out of the box, so you have to use a "plugin" for it (known as a "rule").

So, in the Bazel docs, you'll find a recommended rules page, which directs you to the rules_nodejs repo for JavaScript. The README for this repo is really confusing, but after a while, I came to realize that rules_nodejs is actually not being maintained anymore. Instead, we're supposed to be using the rules_js plugin.

Reading through that README sounds good at first, but it really starts to show where Bazel starts to become a real pain to work with. As far as I can tell, there aren't any corresponding rulesets for using Vite along with the rules_js plugin. You've got rules_jest, rules_cypress, rules_webpack, and a few other interesting ones, but there's nothing ready out-of-the-box for Vite, which is currently the standard JS build/test tool.

davidalucas commented 8 months ago

At this point, I'm finding myself wondering if Bazel is even the right tool for what I want to do here. Maybe the better approach would've been to use Docker instead? Pretty sure I could just make containers for each of the projects, run the builds and tests inside of the containers, output the final build to a directory using volume mounts, and there you go...

There's also always good 'ol GNU Make... I was hoping that Bazel would actually be a more powerful and easier-to-use version of Make, but it appears that's not the case at all. More powerful? Maybe, sure. Easier? Definitely not.