Skip to content

Commit 43024bd

Browse files
authored
feat(bazel): support Karma spec bundling with rules_js (#2697)
We need AMD spec bundling for Karma, until we have our own IIFE-capable ruleset. This is a small layer on top of our much simpler spec bundling rule. Note that we switch to `rules_esbuild` as otherwise Esbuild can escape sandbox due to its Go-based resolution.
1 parent 78f80fa commit 43024bd

File tree

7 files changed

+78
-316
lines changed

7 files changed

+78
-316
lines changed

WORKSPACE

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,23 @@ setup_dependencies_1()
164164
load("//bazel:setup_dependencies_2.bzl", "setup_dependencies_2")
165165

166166
setup_dependencies_2()
167+
168+
# TODO: Move this to the setup scripts. E.g. following proposals like:
169+
# go/ng:sharing-infra-code.
170+
http_archive(
171+
name = "aspect_rules_esbuild",
172+
sha256 = "550e33ddeb86a564b22b2c5d3f84748c6639b1b2b71fae66bf362c33392cbed8",
173+
strip_prefix = "rules_esbuild-0.21.0",
174+
url = "https://github.com/aspect-build/rules_esbuild/releases/download/v0.21.0/rules_esbuild-v0.21.0.tar.gz",
175+
)
176+
177+
load("@aspect_rules_esbuild//esbuild:dependencies.bzl", "rules_esbuild_dependencies")
178+
179+
rules_esbuild_dependencies()
180+
181+
load("@aspect_rules_esbuild//esbuild:repositories.bzl", "LATEST_ESBUILD_VERSION", "esbuild_register_toolchains")
182+
183+
esbuild_register_toolchains(
184+
name = "esbuild",
185+
esbuild_version = LATEST_ESBUILD_VERSION,
186+
)

bazel/karma/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package(default_visibility = ["//visibility:public"])
22

3-
exports_files(["karma-debug-config.js"])
3+
exports_files(["karma-debug-config.cjs"])
44

55
# Make source files available for distribution via pkg_npm
66
filegroup(

bazel/karma/index.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def _karma_debug_browsers_target(name, **web_test_args):
1515
# that is manually connected to.
1616
_karma_web_test(
1717
name = "%s_bin" % name,
18-
config_file = "//bazel/karma:karma-debug-config.js",
18+
config_file = "@devinfra//bazel/karma:karma-debug-config.cjs",
1919
tags = ["manual"],
2020
**web_test_args
2121
)
@@ -24,7 +24,7 @@ def _karma_debug_browsers_target(name, **web_test_args):
2424
native.sh_test(
2525
name = name,
2626
srcs = ["%s_bin" % name],
27-
tags = ["manual", "local", "ibazel_notify_changes"],
27+
tags = ["manual", "requires-network", "ibazel_notify_changes"],
2828
testonly = True,
2929
)
3030

File renamed without changes.

bazel/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
"dependencies": {
44
"@microsoft/api-extractor": "7.52.2",
55
"typescript": "5.8.2",
6-
"@types/node": "22.13.14",
7-
"esbuild": "0.25.2"
6+
"@types/node": "22.13.14"
87
},
98
"pnpm": {
109
"onlyBuiltDependencies": []

0 commit comments

Comments
 (0)