Skip to content

Commit 3bb1147

Browse files
committed
refactor(bazel): drop interop support for spec_bundling tooling (#2928)
Remove interop support for spec_bundle tooling PR Close #2928
1 parent 501e4a4 commit 3bb1147

20 files changed

+943
-173
lines changed

.bazelignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ bazel/integration/tests/angular-cli/node_modules/
66
bazel/integration/tests/nested_bazel_workspaces/node_modules
77
bazel/integration/tests/package_mappings/node_modules/
88
bazel/integration/tests/playwright_chromium/node_modules
9+
10+
bazel/node_modules
11+
bazel/spec-bundling/test/node_modules

WORKSPACE

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,3 +177,14 @@ rules_browsers_setup_1()
177177
load("@rules_browsers//setup:step_2.bzl", "rules_browsers_setup_2")
178178

179179
rules_browsers_setup_2()
180+
181+
http_archive(
182+
name = "aspect_rules_jasmine",
183+
sha256 = "0d2f9c977842685895020cac721d8cc4f1b37aae15af46128cf619741dc61529",
184+
strip_prefix = "rules_jasmine-2.0.0",
185+
url = "https://github.com/aspect-build/rules_jasmine/releases/download/v2.0.0/rules_jasmine-v2.0.0.tar.gz",
186+
)
187+
188+
load("@aspect_rules_jasmine//jasmine:dependencies.bzl", "rules_jasmine_dependencies")
189+
190+
rules_jasmine_dependencies()

bazel/pnpm-lock.yaml

Lines changed: 638 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bazel/pnpm-workspace.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
packages:
2+
- .
3+
- spec-bundling/test/

bazel/setup_dependencies_1.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ def setup_dependencies_1():
66
data = [
77
"@devinfra//bazel:package.json",
88
"@devinfra//bazel:pnpm-workspace.yaml",
9+
"@devinfra//bazel/spec-bundling/test:package.json",
910
],
1011
pnpm_lock = "@devinfra//bazel:pnpm-lock.yaml",
1112
)

bazel/spec-bundling/BUILD.bazel

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package(default_visibility = ["//visibility:public"])
22

3-
exports_files(["esbuild.config-tmpl.mjs"])
4-
53
# Make source files available for distribution via pkg_npm
64
filegroup(
75
name = "files",

bazel/spec-bundling/bundle-config.bzl

Lines changed: 0 additions & 43 deletions
This file was deleted.

bazel/spec-bundling/index.bzl

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,38 @@
1-
"""Public API for rules related to test bundling."""
1+
load("@aspect_rules_esbuild//esbuild:defs.bzl", "esbuild")
2+
load("@devinfra//bazel/spec-bundling:spec-entrypoint.bzl", "spec_entrypoint")
23

3-
load("//bazel/spec-bundling:spec-entrypoint.bzl", _spec_entrypoint = "spec_entrypoint")
4-
load("//bazel/spec-bundling:spec-bundle.bzl", _spec_bundle = "spec_bundle")
4+
def spec_bundle(name, deps, srcs = [], bootstrap = [], testonly = True, config = {}, **kwargs):
5+
spec_entrypoint(
6+
name = "%s_entrypoint" % name,
7+
deps = deps,
8+
bootstrap = bootstrap,
9+
testonly = testonly,
10+
)
511

6-
spec_bundle = _spec_bundle
7-
spec_entrypoint = _spec_entrypoint
12+
esbuild(
13+
name = name,
14+
# Note: `deps` are added here to automatically collect transitive NPM
15+
# sources etc. and make them available for bundling.
16+
srcs = srcs + deps + [
17+
":%s_entrypoint" % name,
18+
],
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),
30+
testonly = testonly,
31+
bundle = True,
32+
format = "iife",
33+
sourcemap = "linked",
34+
platform = kwargs.pop("platform", "node"),
35+
entry_point = ":%s_entrypoint" % name,
36+
output = "%s.spec.js" % name,
37+
**kwargs
38+
)

bazel/spec-bundling/index_rjs.bzl

Lines changed: 0 additions & 51 deletions
This file was deleted.

bazel/spec-bundling/spec-entrypoint.bzl

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
load("@aspect_rules_js//js:providers.bzl", "JsInfo", "js_info")
2-
load("@rules_nodejs//nodejs:providers.bzl", "JSModuleInfo")
32

43
def _is_non_external_file_with_suffix(file, suffix):
54
"""Gets whether the given file is a non-external file with the given suffix."""
@@ -46,8 +45,6 @@ def _spec_entrypoint_impl(ctx):
4645
if JsInfo in dep:
4746
spec_all_deps.append(dep[JsInfo].transitive_sources)
4847
spec_all_deps.append(dep[JsInfo].npm_sources)
49-
elif JSModuleInfo in dep:
50-
spec_all_deps.append(dep[JSModuleInfo].sources)
5148
else:
5249
spec_all_deps.append(dep[DefaultInfo].files)
5350

@@ -56,9 +53,6 @@ def _spec_entrypoint_impl(ctx):
5653
bootstrap_all_deps.append(dep[JsInfo].transitive_sources)
5754
bootstrap_all_deps.append(dep[JsInfo].npm_sources)
5855
bootstrap_direct_deps.append(dep[JsInfo].sources)
59-
elif JSModuleInfo in dep:
60-
bootstrap_all_deps.append(dep[JSModuleInfo].sources)
61-
bootstrap_direct_deps.append(dep[JSModuleInfo].direct_sources)
6256
else:
6357
bootstrap_all_deps.append(dep[DefaultInfo].files)
6458
bootstrap_direct_deps.append(dep[DefaultInfo].files)
@@ -91,10 +85,6 @@ def _spec_entrypoint_impl(ctx):
9185
sources = out_depset,
9286
transitive_sources = transitive_deps,
9387
),
94-
JSModuleInfo(
95-
direct_sources = out_depset,
96-
sources = transitive_deps,
97-
),
9888
]
9989

10090
spec_entrypoint = rule(

0 commit comments

Comments
 (0)