Skip to content

Commit 2a3cbd4

Browse files
authored
fix(bazel): improve spec bundling to preserve original names (#2699)
This will be useful when tests assert on e.g. class `constructor.name` fields.
1 parent 43024bd commit 2a3cbd4

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

bazel/spec-bundling/index_rjs.bzl

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
load("@aspect_rules_esbuild//esbuild:defs.bzl", "esbuild")
22
load("@devinfra//bazel/spec-bundling:spec-entrypoint.bzl", "spec_entrypoint")
33

4-
def spec_bundle(name, deps, bootstrap = [], testonly = True, **kwargs):
4+
def spec_bundle(name, deps, bootstrap = [], testonly = True, config = {}, **kwargs):
55
spec_entrypoint(
66
name = "%s_entrypoint" % name,
77
deps = deps,
@@ -16,6 +16,17 @@ def spec_bundle(name, deps, bootstrap = [], testonly = True, **kwargs):
1616
srcs = deps + [
1717
":%s_entrypoint" % name,
1818
],
19+
config = dict({
20+
# Bundling specs may result in classes being aliased to avoid collisions. e.g. when
21+
# everything is bundled into a single AMD bundle. To avoid test failures for assertions
22+
# on symbol names, we instruct ESBuild to keep original names. See:
23+
# https://esbuild.github.io/api/#keep-names.
24+
"keepNames": True,
25+
# Needed for ZoneJS async await
26+
"supported": {
27+
"async-await": False,
28+
},
29+
}, **config),
1930
testonly = testonly,
2031
bundle = True,
2132
format = "iife",

0 commit comments

Comments
 (0)