Migrate from rules_nodejs to rules_js
This patch is huge because I can't easily break it into smaller
pieces. This is largely because a few things are changing with the
migration.
Firstly, we're upgrading the angular libraries and our version of
typescript. This is actually not too disruptive. It required some
changes in the top-level `package.json` file.
Secondly, the new rules have this concept of copying everything into
the `bazel-bin` directory and executing out of there. This makes the
various tools like node and angular happy, but means that a few file
paths are changing. For example, the `common.css` file can't have the
same path in the source tree as it does in the `bazel-bin` tree, so I
moved it to a `common` directory inside the `bazel-bin` tree. You can
read more about this here:
https://docs.aspect.build/rules/aspect_rules_js#running-nodejs-programs
Thirdly, I couldn't find a simple way to support Protractor in
rules_js. Protractor is the end-to-end testing framework we use for
the scouting application. Since protractor is getting deprecated and
won't receive any more updates, it's time to move to something else.
We settled on Cypress because it appears to be popular and should make
debugging easier for the students. For example, it takes screenshots
of the browser when an assertion fails. It would have been ideal to
switch to Cypress before this migration, but I couldn't find a simple
way to make that work with rules_nodejs. In other words, this
migration patch is huge in part because we are also switching testing
frameworks at the same time. I wanted to split it out, but it was more
difficult than I would have liked.
Fourthly, I also needed to migrate the flatbuffer rules. This I think
is relatively low impact, but it again means that this patch is bigger
than I wanted it to be.
Signed-off-by: Philipp Schrader <philipp.schrader@gmail.com>
Change-Id: I6674874f985952f2e3ef40274da0a2fb9e5631a7
diff --git a/BUILD b/BUILD
index 413620d..2092844 100644
--- a/BUILD
+++ b/BUILD
@@ -1,10 +1,41 @@
load("@bazel_gazelle//:def.bzl", "gazelle")
+load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
+load("@npm//:defs.bzl", "npm_link_all_packages")
+load("@aspect_rules_js//npm:defs.bzl", "npm_link_package")
+
+# Link npm packages
+npm_link_all_packages(name = "node_modules")
exports_files([
"tsconfig.json",
+ "tsconfig.node.json",
"rollup.config.js",
])
+# The root repo tsconfig
+ts_config(
+ name = "tsconfig",
+ src = "tsconfig.json",
+ visibility = ["//visibility:public"],
+)
+
+ts_config(
+ name = "tsconfig.node",
+ src = "tsconfig.node.json",
+ visibility = ["//visibility:public"],
+ deps = [":tsconfig"],
+)
+
+npm_link_package(
+ name = "node_modules/flatbuffers",
+ src = "@com_github_google_flatbuffers//ts:flatbuffers",
+)
+
+npm_link_package(
+ name = "node_modules/flatbuffers_reflection",
+ src = "@com_github_google_flatbuffers//reflection:flatbuffers_reflection",
+)
+
# gazelle:prefix github.com/frc971/971-Robot-Code
# gazelle:build_file_name BUILD
# gazelle:proto disable