From 37adfc2dddf2d455aaa819739066144f9c47b38d Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Tue, 1 Apr 2025 13:41:52 +0000 Subject: [PATCH] fix(bazel): improve spec bundling to preserve original names This will be useful when tests assert on e.g. class `constructor.name` fields. --- bazel/spec-bundling/index_rjs.bzl | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/bazel/spec-bundling/index_rjs.bzl b/bazel/spec-bundling/index_rjs.bzl index c3773990b..2b4fe2a6c 100644 --- a/bazel/spec-bundling/index_rjs.bzl +++ b/bazel/spec-bundling/index_rjs.bzl @@ -1,7 +1,7 @@ load("@aspect_rules_esbuild//esbuild:defs.bzl", "esbuild") load("@devinfra//bazel/spec-bundling:spec-entrypoint.bzl", "spec_entrypoint") -def spec_bundle(name, deps, bootstrap = [], testonly = True, **kwargs): +def spec_bundle(name, deps, bootstrap = [], testonly = True, config = {}, **kwargs): spec_entrypoint( name = "%s_entrypoint" % name, deps = deps, @@ -16,6 +16,17 @@ def spec_bundle(name, deps, bootstrap = [], testonly = True, **kwargs): srcs = deps + [ ":%s_entrypoint" % name, ], + config = dict({ + # Bundling specs may result in classes being aliased to avoid collisions. e.g. when + # everything is bundled into a single AMD bundle. To avoid test failures for assertions + # on symbol names, we instruct ESBuild to keep original names. See: + # https://esbuild.github.io/api/#keep-names. + "keepNames": True, + # Needed for ZoneJS async await + "supported": { + "async-await": False, + }, + }, **config), testonly = testonly, bundle = True, format = "iife",