From 60da69e2d7160487c710e1f658f948133fa99d6e Mon Sep 17 00:00:00 2001 From: eric-higgins-ai Date: Sun, 18 Aug 2024 11:37:40 -0700 Subject: [PATCH 1/3] bazel: migrate to rules_js --- bazel/README.md | 3 +++ bazel/WORKSPACE | 4 ++++ bazel/deps.bzl | 13 ++++--------- bazel/emscripten_deps.bzl | 35 ++++++++++++++++++----------------- 4 files changed, 29 insertions(+), 26 deletions(-) diff --git a/bazel/README.md b/bazel/README.md index 8a4eda1f6d..804f7fae69 100644 --- a/bazel/README.md +++ b/bazel/README.md @@ -15,6 +15,9 @@ git_repository( load("@emsdk//:deps.bzl", emsdk_deps = "deps") emsdk_deps() +load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") +rules_js_dependencies() + load("@emsdk//:emscripten_deps.bzl", emsdk_emscripten_deps = "emscripten_deps") emsdk_emscripten_deps(emscripten_version = "2.0.31") diff --git a/bazel/WORKSPACE b/bazel/WORKSPACE index bd5cce5b0e..953c69d30b 100644 --- a/bazel/WORKSPACE +++ b/bazel/WORKSPACE @@ -4,6 +4,10 @@ load(":deps.bzl", "deps") deps() +load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") + +rules_js_dependencies() + load(":emscripten_deps.bzl", "emscripten_deps") emscripten_deps() diff --git a/bazel/deps.bzl b/bazel/deps.bzl index a83cfaf847..6e00de2621 100644 --- a/bazel/deps.bzl +++ b/bazel/deps.bzl @@ -22,13 +22,8 @@ def deps(): ) maybe( http_archive, - name = "rules_nodejs", - sha256 = "08337d4fffc78f7fe648a93be12ea2fc4e8eb9795a4e6aa48595b66b34555626", - urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.8.0/rules_nodejs-core-5.8.0.tar.gz"], - ) - maybe( - http_archive, - name = "build_bazel_rules_nodejs", - sha256 = "dcc55f810142b6cf46a44d0180a5a7fb923c04a5061e2e8d8eb05ccccc60864b", - urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.8.0/rules_nodejs-5.8.0.tar.gz"], + name = "aspect_rules_js", + strip_prefix = "rules_js-2.0.0", + sha256 = "6b7e73c35b97615a09281090da3645d9f03b2a09e8caa791377ad9022c88e2e6", + urls = ["https://github.com/aspect-build/rules_js/releases/download/v2.0.0/rules_js-v2.0.0.tar.gz"], ) diff --git a/bazel/emscripten_deps.bzl b/bazel/emscripten_deps.bzl index 16fd8ee1c6..93e6c4016b 100644 --- a/bazel/emscripten_deps.bzl +++ b/bazel/emscripten_deps.bzl @@ -1,5 +1,6 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -load("@build_bazel_rules_nodejs//:index.bzl", "node_repositories", "npm_install") +load("@aspect_rules_js//js:toolchains.bzl", "rules_js_register_toolchains") +load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") load(":revisions.bzl", "EMSCRIPTEN_TAGS") def _parse_version(v): @@ -118,7 +119,7 @@ def emscripten_deps(emscripten_version = "latest"): excludes = native.existing_rules().keys() if "nodejs_toolchains" not in excludes: # Node 16 is the first version that supports darwin_arm64 - node_repositories( + rules_js_register_toolchains( node_version = "16.6.2", ) @@ -174,36 +175,36 @@ def emscripten_deps(emscripten_version = "latest"): ) if "emscripten_npm_linux" not in excludes: - npm_install( + npm_translate_lock( name = "emscripten_npm_linux", - package_json = "@emscripten_bin_linux//:emscripten/package.json", - package_lock_json = "@emscripten_bin_linux//:emscripten/package-lock.json", + data = ["@emscripten_bin_linux//:emscripten/package.json"], + npm_package_lock = "@emscripten_bin_linux//:emscripten/package-lock.json", ) if "emscripten_npm_linux_arm64" not in excludes: - npm_install( + npm_translate_lock( name = "emscripten_npm_linux_arm64", - package_json = "@emscripten_bin_linux_arm64//:emscripten/package.json", - package_lock_json = "@emscripten_bin_linux_arm64//:emscripten/package-lock.json", + data = ["@emscripten_bin_linux_arm64//:emscripten/package.json"], + npm_package_lock = "@emscripten_bin_linux_arm64//:emscripten/package-lock.json", ) if "emscripten_npm_mac" not in excludes: - npm_install( + npm_translate_lock( name = "emscripten_npm_mac", - package_json = "@emscripten_bin_mac//:emscripten/package.json", - package_lock_json = "@emscripten_bin_mac//:emscripten/package-lock.json", + data = ["@emscripten_bin_mac//:emscripten/package.json"], + npm_package_lock = "@emscripten_bin_mac//:emscripten/package-lock.json", ) if "emscripten_npm_mac_arm64" not in excludes: - npm_install( + npm_translate_lock( name = "emscripten_npm_mac", - package_json = "@emscripten_bin_mac_arm64//:emscripten/package.json", - package_lock_json = "@emscripten_bin_mac_arm64//:emscripten/package-lock.json", + data = ["@emscripten_bin_mac_arm64//:emscripten/package.json"], + npm_package_lock = "@emscripten_bin_mac_arm64//:emscripten/package-lock.json", ) if "emscripten_npm_win" not in excludes: - npm_install( + npm_translate_lock( name = "emscripten_npm_win", - package_json = "@emscripten_bin_win//:emscripten/package.json", - package_lock_json = "@emscripten_bin_win//:emscripten/package-lock.json", + data = ["@emscripten_bin_win//:emscripten/package.json"], + npm_package_lock = "@emscripten_bin_win//:emscripten/package-lock.json", ) From e0e59a821a25357eae6bc90cde40a5cfa58c4c96 Mon Sep 17 00:00:00 2001 From: eric-higgins-ai Date: Sun, 18 Aug 2024 11:49:09 -0700 Subject: [PATCH 2/3] don't make a breaking change --- bazel/README.md | 3 --- bazel/deps.bzl | 13 ++++++++++--- bazel/emscripten_deps.bzl | 4 ++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/bazel/README.md b/bazel/README.md index 804f7fae69..8a4eda1f6d 100644 --- a/bazel/README.md +++ b/bazel/README.md @@ -15,9 +15,6 @@ git_repository( load("@emsdk//:deps.bzl", emsdk_deps = "deps") emsdk_deps() -load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") -rules_js_dependencies() - load("@emsdk//:emscripten_deps.bzl", emsdk_emscripten_deps = "emscripten_deps") emsdk_emscripten_deps(emscripten_version = "2.0.31") diff --git a/bazel/deps.bzl b/bazel/deps.bzl index 6e00de2621..143b761842 100644 --- a/bazel/deps.bzl +++ b/bazel/deps.bzl @@ -20,10 +20,17 @@ def deps(): "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.1.1/bazel-skylib-1.1.1.tar.gz", ], ) + maybe( + http_archive, + name = "rules_nodejs", + strip_prefix = "rules_nodejs-6.2.0", + sha256 = "87c6171c5be7b69538d4695d9ded29ae2626c5ed76a9adeedce37b63c73bef67", + urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/v6.2.0/rules_nodejs-v6.2.0.tar.gz"], + ) maybe( http_archive, name = "aspect_rules_js", - strip_prefix = "rules_js-2.0.0", - sha256 = "6b7e73c35b97615a09281090da3645d9f03b2a09e8caa791377ad9022c88e2e6", - urls = ["https://github.com/aspect-build/rules_js/releases/download/v2.0.0/rules_js-v2.0.0.tar.gz"], + strip_prefix = "rules_js-1.42.0", + sha256 = "5a00869efaeb308245f8132a671fe86524bdfc4f8bfd1976d26f862b316dc3c9", + urls = ["https://github.com/aspect-build/rules_js/releases/download/v1.42.0/rules_js-v1.42.0.tar.gz"], ) diff --git a/bazel/emscripten_deps.bzl b/bazel/emscripten_deps.bzl index 93e6c4016b..d3edf67703 100644 --- a/bazel/emscripten_deps.bzl +++ b/bazel/emscripten_deps.bzl @@ -1,5 +1,5 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -load("@aspect_rules_js//js:toolchains.bzl", "rules_js_register_toolchains") +load("@rules_nodejs//nodejs:repositories.bzl", "nodejs_register_toolchains") load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") load(":revisions.bzl", "EMSCRIPTEN_TAGS") @@ -119,7 +119,7 @@ def emscripten_deps(emscripten_version = "latest"): excludes = native.existing_rules().keys() if "nodejs_toolchains" not in excludes: # Node 16 is the first version that supports darwin_arm64 - rules_js_register_toolchains( + nodejs_register_toolchains( node_version = "16.6.2", ) From 9a5421ae796cd3d67a7686e5271065407453b094 Mon Sep 17 00:00:00 2001 From: eric-higgins-ai Date: Sun, 18 Aug 2024 12:00:57 -0700 Subject: [PATCH 3/3] fix tests? --- bazel/WORKSPACE | 4 ---- bazel/deps.bzl | 27 +++++++++++++++++++++------ 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/bazel/WORKSPACE b/bazel/WORKSPACE index 953c69d30b..bd5cce5b0e 100644 --- a/bazel/WORKSPACE +++ b/bazel/WORKSPACE @@ -4,10 +4,6 @@ load(":deps.bzl", "deps") deps() -load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") - -rules_js_dependencies() - load(":emscripten_deps.bzl", "emscripten_deps") emscripten_deps() diff --git a/bazel/deps.bzl b/bazel/deps.bzl index 143b761842..d622e2addb 100644 --- a/bazel/deps.bzl +++ b/bazel/deps.bzl @@ -20,6 +20,22 @@ def deps(): "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.1.1/bazel-skylib-1.1.1.tar.gz", ], ) + maybe( + http_archive, + name = "aspect_rules_js", + strip_prefix = "rules_js-1.42.0", + sha256 = "5a00869efaeb308245f8132a671fe86524bdfc4f8bfd1976d26f862b316dc3c9", + urls = ["https://github.com/aspect-build/rules_js/releases/download/v1.42.0/rules_js-v1.42.0.tar.gz"], + ) + # Transitive dependencies of aspect_rules_js. We explicitly pull them here instead of calling their + # provided function to avoid requiring a call to rules_js_dependencies in WORKSPACE. + maybe( + http_archive, + name = "aspect_bazel_lib", + sha256 = "714cf8ce95a198bab0a6a3adaffea99e929d2f01bf6d4a59a2e6d6af72b4818c", + strip_prefix = "bazel-lib-2.7.8", + url = "https://github.com/aspect-build/bazel-lib/releases/download/v2.7.8/bazel-lib-v2.7.8.tar.gz", + ) maybe( http_archive, name = "rules_nodejs", @@ -27,10 +43,9 @@ def deps(): sha256 = "87c6171c5be7b69538d4695d9ded29ae2626c5ed76a9adeedce37b63c73bef67", urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/v6.2.0/rules_nodejs-v6.2.0.tar.gz"], ) - maybe( - http_archive, - name = "aspect_rules_js", - strip_prefix = "rules_js-1.42.0", - sha256 = "5a00869efaeb308245f8132a671fe86524bdfc4f8bfd1976d26f862b316dc3c9", - urls = ["https://github.com/aspect-build/rules_js/releases/download/v1.42.0/rules_js-v1.42.0.tar.gz"], + http_archive( + name = "bazel_features", + sha256 = "f3082bfcdca73dc77dcd68faace806135a2e08c230b02b1d9fbdbd7db9d9c450", + strip_prefix = "bazel_features-0.1.0", + url = "https://github.com/bazel-contrib/bazel_features/releases/download/v0.1.0/bazel_features-v0.1.0.tar.gz", )