Skip to content

refactor(bazel): drop interop support for spec_bundling tooling #2928

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ bazel/integration/tests/angular-cli/node_modules/
bazel/integration/tests/nested_bazel_workspaces/node_modules
bazel/integration/tests/package_mappings/node_modules/
bazel/integration/tests/playwright_chromium/node_modules

bazel/node_modules
bazel/spec-bundling/test/node_modules
11 changes: 11 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,14 @@ rules_browsers_setup_1()
load("@rules_browsers//setup:step_2.bzl", "rules_browsers_setup_2")

rules_browsers_setup_2()

http_archive(
name = "aspect_rules_jasmine",
sha256 = "0d2f9c977842685895020cac721d8cc4f1b37aae15af46128cf619741dc61529",
strip_prefix = "rules_jasmine-2.0.0",
url = "https://github.com/aspect-build/rules_jasmine/releases/download/v2.0.0/rules_jasmine-v2.0.0.tar.gz",
)

load("@aspect_rules_jasmine//jasmine:dependencies.bzl", "rules_jasmine_dependencies")

rules_jasmine_dependencies()
642 changes: 638 additions & 4 deletions bazel/pnpm-lock.yaml

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions bazel/pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
packages:
- .
- spec-bundling/test/
1 change: 1 addition & 0 deletions bazel/setup_dependencies_1.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ def setup_dependencies_1():
data = [
"@devinfra//bazel:package.json",
"@devinfra//bazel:pnpm-workspace.yaml",
"@devinfra//bazel/spec-bundling/test:package.json",
],
pnpm_lock = "@devinfra//bazel:pnpm-lock.yaml",
)
2 changes: 0 additions & 2 deletions bazel/spec-bundling/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package(default_visibility = ["//visibility:public"])

exports_files(["esbuild.config-tmpl.mjs"])

# Make source files available for distribution via pkg_npm
filegroup(
name = "files",
Expand Down
43 changes: 0 additions & 43 deletions bazel/spec-bundling/bundle-config.bzl

This file was deleted.

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

load("//bazel/spec-bundling:spec-entrypoint.bzl", _spec_entrypoint = "spec_entrypoint")
load("//bazel/spec-bundling:spec-bundle.bzl", _spec_bundle = "spec_bundle")
def spec_bundle(name, deps, srcs = [], bootstrap = [], testonly = True, config = {}, **kwargs):
spec_entrypoint(
name = "%s_entrypoint" % name,
deps = deps,
bootstrap = bootstrap,
testonly = testonly,
)

spec_bundle = _spec_bundle
spec_entrypoint = _spec_entrypoint
esbuild(
name = name,
# Note: `deps` are added here to automatically collect transitive NPM
# sources etc. and make them available for bundling.
srcs = 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",
sourcemap = "linked",
platform = kwargs.pop("platform", "node"),
entry_point = ":%s_entrypoint" % name,
output = "%s.spec.js" % name,
**kwargs
)
51 changes: 0 additions & 51 deletions bazel/spec-bundling/index_rjs.bzl

This file was deleted.

10 changes: 0 additions & 10 deletions bazel/spec-bundling/spec-entrypoint.bzl
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
load("@aspect_rules_js//js:providers.bzl", "JsInfo", "js_info")
load("@rules_nodejs//nodejs:providers.bzl", "JSModuleInfo")

def _is_non_external_file_with_suffix(file, suffix):
"""Gets whether the given file is a non-external file with the given suffix."""
Expand Down Expand Up @@ -46,8 +45,6 @@ def _spec_entrypoint_impl(ctx):
if JsInfo in dep:
spec_all_deps.append(dep[JsInfo].transitive_sources)
spec_all_deps.append(dep[JsInfo].npm_sources)
elif JSModuleInfo in dep:
spec_all_deps.append(dep[JSModuleInfo].sources)
else:
spec_all_deps.append(dep[DefaultInfo].files)

Expand All @@ -56,9 +53,6 @@ def _spec_entrypoint_impl(ctx):
bootstrap_all_deps.append(dep[JsInfo].transitive_sources)
bootstrap_all_deps.append(dep[JsInfo].npm_sources)
bootstrap_direct_deps.append(dep[JsInfo].sources)
elif JSModuleInfo in dep:
bootstrap_all_deps.append(dep[JSModuleInfo].sources)
bootstrap_direct_deps.append(dep[JSModuleInfo].direct_sources)
else:
bootstrap_all_deps.append(dep[DefaultInfo].files)
bootstrap_direct_deps.append(dep[DefaultInfo].files)
Expand Down Expand Up @@ -91,10 +85,6 @@ def _spec_entrypoint_impl(ctx):
sources = out_depset,
transitive_sources = transitive_deps,
),
JSModuleInfo(
direct_sources = out_depset,
sources = transitive_deps,
),
]

spec_entrypoint = rule(
Expand Down
Loading