Skip to content

Commit

Permalink
build(bazel): upgrade to rules_js 2.0 RC
Browse files Browse the repository at this point in the history
  • Loading branch information
gregmagolan authored and Strum355 committed Jun 4, 2024
1 parent 1a7e1b9 commit 59be5e4
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 159 deletions.
42 changes: 15 additions & 27 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -33,33 +33,25 @@ http_archive(
url = "https://github.com/aspect-build/bazel-lib/releases/download/v2.7.7/bazel-lib-v2.7.7.tar.gz",
)

# rules_js defines an older rules_nodejs, so we override it here
http_archive(
name = "rules_nodejs",
sha256 = "3e8369256ad63197959d2253c473a9dcc57c2841d176190e59b91d25d4fe9e67",
strip_prefix = "rules_nodejs-6.1.1",
url = "https://github.com/bazelbuild/rules_nodejs/releases/download/v6.1.1/rules_nodejs-v6.1.1.tar.gz",
)

http_archive(
name = "aspect_rules_js",
sha256 = "2cfb3875e1231cefd3fada6774f2c0c5a99db0070e0e48ea398acbff7c6c765b",
strip_prefix = "rules_js-1.42.3",
url = "https://github.com/aspect-build/rules_js/releases/download/v1.42.3/rules_js-v1.42.3.tar.gz",
sha256 = "25e06ac98ce2dd44d74e728e63e1c88e707d0972db20d7e7339c8e458335b4e3",
strip_prefix = "rules_js-2.0.0-rc2",
url = "https://github.com/aspect-build/rules_js/releases/download/v2.0.0-rc2/rules_js-v2.0.0-rc2.tar.gz",
)

http_archive(
name = "aspect_rules_ts",
sha256 = "da6620683ab2c28014e9c82e8a8fdbb724cd67f6a1d27317f42a8ceb14048b9b",
strip_prefix = "rules_ts-2.4.1",
url = "https://github.com/aspect-build/rules_ts/releases/download/v2.4.1/rules_ts-v2.4.1.tar.gz",
sha256 = "3ea5cdb825d5dbffe286b3d9c5197a2648cf04b5e6bd8b913a45823cdf0ae960",
strip_prefix = "rules_ts-3.0.0-rc0",
url = "https://github.com/aspect-build/rules_ts/releases/download/v3.0.0-rc0/rules_ts-v3.0.0-rc0.tar.gz",
)

http_archive(
name = "aspect_rules_swc",
sha256 = "1908691bde56321423c3f3beaf37f5fc21c51614869572e5f626cea058649373",
strip_prefix = "rules_swc-1.2.3",
url = "https://github.com/aspect-build/rules_swc/releases/download/v1.2.3/rules_swc-v1.2.3.tar.gz",
sha256 = "c085647585c3d01bee3966eb9ba433a1efbb0ee79bb1b8c67882a81d82a9b37f",
strip_prefix = "rules_swc-2.0.0-rc0",
url = "https://github.com/aspect-build/rules_swc/releases/download/v2.0.0-rc0/rules_swc-v2.0.0-rc0.tar.gz",
)

http_archive(
Expand Down Expand Up @@ -207,16 +199,12 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies")

rules_js_dependencies()

# node toolchain setup ==========================
load("@rules_nodejs//nodejs:repositories.bzl", "nodejs_register_toolchains")
load("@aspect_rules_js//js:toolchains.bzl", "rules_js_register_toolchains")

nodejs_register_toolchains(
name = "nodejs",
node_version = "20.8.0",
)
rules_js_register_toolchains(node_version = "20.8.0")

# rules_js npm setup ============================
load("@aspect_rules_js//npm:npm_import.bzl", "npm_translate_lock")
load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock")

npm_translate_lock(
name = "npm",
Expand Down Expand Up @@ -270,9 +258,9 @@ swc_register_toolchains(
# rules_esbuild setup ===========================
http_archive(
name = "aspect_rules_esbuild",
sha256 = "46aab76044f040c1c0bd97672d56324619af4913cb9e96606ec37ddd4605831d",
strip_prefix = "rules_esbuild-0.16.0",
url = "https://github.com/aspect-build/rules_esbuild/releases/download/v0.16.0/rules_esbuild-v0.16.0.tar.gz",
sha256 = "ef7163a2e8e319f8a9a70560788dd899126aebf3538c76f8bc1f0b4b52ba4b56",
strip_prefix = "rules_esbuild-0.21.0-rc1",
url = "https://github.com/aspect-build/rules_esbuild/releases/download/v0.21.0-rc1/rules_esbuild-v0.21.0-rc1.tar.gz",
)

load("@aspect_rules_esbuild//esbuild:dependencies.bzl", "rules_esbuild_dependencies")
Expand Down
4 changes: 4 additions & 0 deletions dev/esbuild.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ load("@aspect_rules_esbuild//esbuild:defs.bzl", _esbuild = "esbuild")
def esbuild(name, **kwargs):
_esbuild(
name,
# TODO: work through build failures when sandbox plugin is enabled so that bundling is hermetic
bazel_sandbox_plugin = False,
**kwargs
)

Expand All @@ -12,6 +14,8 @@ def esbuild_web_app(name, **kwargs):

_esbuild(
name = bundle_name,
# TODO: work through build failures when sandbox plugin is enabled so that bundling is hermetic
bazel_sandbox_plugin = False,
**kwargs
)

Expand Down
12 changes: 6 additions & 6 deletions dev/eslint.bzl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "COPY_FILE_TO_BIN_TOOLCHAINS", "copy_files_to_bin_actions")
load("@aspect_rules_js//js:defs.bzl", "js_library")
load("@aspect_rules_js//js:libs.bzl", "js_lib_helpers")
load("@aspect_rules_js//js:providers.bzl", "JsInfo")
load("//dev:js_lib.bzl", "gather_files_from_js_providers", "gather_runfiles")

def eslint_config_and_lint_root(name = "eslint_config", config_deps = [], root_js_deps = []):
"""
Expand Down Expand Up @@ -58,17 +58,17 @@ def _custom_eslint_impl(ctx):

inputs_depset = depset(
copied_srcs + [ctx.executable.binary],
transitive = [gather_files_from_js_providers(
transitive = [js_lib_helpers.gather_files_from_js_infos(
targets = [ctx.attr.config] + ctx.attr.deps,
include_sources = False,
include_types = True, # we have to include types because we need to lint the types.
include_transitive_sources = False,
# We have to include declarations because we need to lint the types.
include_declarations = True,
include_npm_linked_packages = True,
include_transitive_types = True, # we have to include types because we need to lint the types.
include_npm_sources = True,
)],
)

runfiles = gather_runfiles(
runfiles = js_lib_helpers.gather_runfiles(
ctx = ctx,
sources = [],
data = [ctx.attr.config],
Expand Down
126 changes: 0 additions & 126 deletions dev/js_lib.bzl

This file was deleted.

2 changes: 2 additions & 0 deletions dev/mocha.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ def mocha_test(name, tests, deps = [], args = [], data = [], env = {}, is_percy_
".node": "copy",
},
},
# TODO: work through build failures when sandbox plugin is enabled so that bundling is hermetic
bazel_sandbox_plugin = False,
)

args = [
Expand Down

0 comments on commit 59be5e4

Please sign in to comment.