From c7b48a4844906a28d149aa804062069f49a8d8d4 Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Mon, 31 Mar 2025 20:55:34 +0000 Subject: [PATCH] feat(bazel): support Karma spec bundling with `rules_js` 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. --- WORKSPACE | 20 ++ bazel/karma/BUILD.bazel | 2 +- bazel/karma/index.bzl | 4 +- ...debug-config.js => karma-debug-config.cjs} | 0 bazel/package.json | 3 +- bazel/pnpm-lock.yaml | 325 ++---------------- bazel/spec-bundling/index_rjs.bzl | 40 ++- 7 files changed, 78 insertions(+), 316 deletions(-) rename bazel/karma/{karma-debug-config.js => karma-debug-config.cjs} (100%) diff --git a/WORKSPACE b/WORKSPACE index 4b90dfb35..74aa67df1 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -164,3 +164,23 @@ setup_dependencies_1() load("//bazel:setup_dependencies_2.bzl", "setup_dependencies_2") setup_dependencies_2() + +# TODO: Move this to the setup scripts. E.g. following proposals like: +# go/ng:sharing-infra-code. +http_archive( + name = "aspect_rules_esbuild", + sha256 = "550e33ddeb86a564b22b2c5d3f84748c6639b1b2b71fae66bf362c33392cbed8", + strip_prefix = "rules_esbuild-0.21.0", + url = "https://github.com/aspect-build/rules_esbuild/releases/download/v0.21.0/rules_esbuild-v0.21.0.tar.gz", +) + +load("@aspect_rules_esbuild//esbuild:dependencies.bzl", "rules_esbuild_dependencies") + +rules_esbuild_dependencies() + +load("@aspect_rules_esbuild//esbuild:repositories.bzl", "LATEST_ESBUILD_VERSION", "esbuild_register_toolchains") + +esbuild_register_toolchains( + name = "esbuild", + esbuild_version = LATEST_ESBUILD_VERSION, +) diff --git a/bazel/karma/BUILD.bazel b/bazel/karma/BUILD.bazel index d85c98bd8..cfaaa6e52 100644 --- a/bazel/karma/BUILD.bazel +++ b/bazel/karma/BUILD.bazel @@ -1,6 +1,6 @@ package(default_visibility = ["//visibility:public"]) -exports_files(["karma-debug-config.js"]) +exports_files(["karma-debug-config.cjs"]) # Make source files available for distribution via pkg_npm filegroup( diff --git a/bazel/karma/index.bzl b/bazel/karma/index.bzl index 8d3e7af51..faf61967d 100644 --- a/bazel/karma/index.bzl +++ b/bazel/karma/index.bzl @@ -15,7 +15,7 @@ def _karma_debug_browsers_target(name, **web_test_args): # that is manually connected to. _karma_web_test( name = "%s_bin" % name, - config_file = "//bazel/karma:karma-debug-config.js", + config_file = "@devinfra//bazel/karma:karma-debug-config.cjs", tags = ["manual"], **web_test_args ) @@ -24,7 +24,7 @@ def _karma_debug_browsers_target(name, **web_test_args): native.sh_test( name = name, srcs = ["%s_bin" % name], - tags = ["manual", "local", "ibazel_notify_changes"], + tags = ["manual", "requires-network", "ibazel_notify_changes"], testonly = True, ) diff --git a/bazel/karma/karma-debug-config.js b/bazel/karma/karma-debug-config.cjs similarity index 100% rename from bazel/karma/karma-debug-config.js rename to bazel/karma/karma-debug-config.cjs diff --git a/bazel/package.json b/bazel/package.json index fb5893807..9ce3fc955 100644 --- a/bazel/package.json +++ b/bazel/package.json @@ -3,8 +3,7 @@ "dependencies": { "@microsoft/api-extractor": "7.52.2", "typescript": "5.8.2", - "@types/node": "22.13.14", - "esbuild": "0.25.2" + "@types/node": "22.13.14" }, "pnpm": { "onlyBuiltDependencies": [] diff --git a/bazel/pnpm-lock.yaml b/bazel/pnpm-lock.yaml index fdf4c0380..d950564c4 100644 --- a/bazel/pnpm-lock.yaml +++ b/bazel/pnpm-lock.yaml @@ -9,175 +9,22 @@ importers: .: dependencies: '@microsoft/api-extractor': - specifier: 7.52.1 - version: 7.52.1(@types/node@22.13.11) + specifier: 7.52.2 + version: 7.52.2(@types/node@22.13.14) '@types/node': - specifier: 22.13.11 - version: 22.13.11 - esbuild: - specifier: 0.25.1 - version: 0.25.1 + specifier: 22.13.14 + version: 22.13.14 typescript: specifier: 5.8.2 version: 5.8.2 packages: - '@esbuild/aix-ppc64@0.25.1': - resolution: {integrity: sha512-kfYGy8IdzTGy+z0vFGvExZtxkFlA4zAxgKEahG9KE1ScBjpQnFsNOX8KTU5ojNru5ed5CVoJYXFtoxaq5nFbjQ==} - engines: {node: '>=18'} - cpu: [ppc64] - os: [aix] - - '@esbuild/android-arm64@0.25.1': - resolution: {integrity: sha512-50tM0zCJW5kGqgG7fQ7IHvQOcAn9TKiVRuQ/lN0xR+T2lzEFvAi1ZcS8DiksFcEpf1t/GYOeOfCAgDHFpkiSmA==} - engines: {node: '>=18'} - cpu: [arm64] - os: [android] - - '@esbuild/android-arm@0.25.1': - resolution: {integrity: sha512-dp+MshLYux6j/JjdqVLnMglQlFu+MuVeNrmT5nk6q07wNhCdSnB7QZj+7G8VMUGh1q+vj2Bq8kRsuyA00I/k+Q==} - engines: {node: '>=18'} - cpu: [arm] - os: [android] - - '@esbuild/android-x64@0.25.1': - resolution: {integrity: sha512-GCj6WfUtNldqUzYkN/ITtlhwQqGWu9S45vUXs7EIYf+7rCiiqH9bCloatO9VhxsL0Pji+PF4Lz2XXCES+Q8hDw==} - engines: {node: '>=18'} - cpu: [x64] - os: [android] - - '@esbuild/darwin-arm64@0.25.1': - resolution: {integrity: sha512-5hEZKPf+nQjYoSr/elb62U19/l1mZDdqidGfmFutVUjjUZrOazAtwK+Kr+3y0C/oeJfLlxo9fXb1w7L+P7E4FQ==} - engines: {node: '>=18'} - cpu: [arm64] - os: [darwin] - - '@esbuild/darwin-x64@0.25.1': - resolution: {integrity: sha512-hxVnwL2Dqs3fM1IWq8Iezh0cX7ZGdVhbTfnOy5uURtao5OIVCEyj9xIzemDi7sRvKsuSdtCAhMKarxqtlyVyfA==} - engines: {node: '>=18'} - cpu: [x64] - os: [darwin] - - '@esbuild/freebsd-arm64@0.25.1': - resolution: {integrity: sha512-1MrCZs0fZa2g8E+FUo2ipw6jw5qqQiH+tERoS5fAfKnRx6NXH31tXBKI3VpmLijLH6yriMZsxJtaXUyFt/8Y4A==} - engines: {node: '>=18'} - cpu: [arm64] - os: [freebsd] - - '@esbuild/freebsd-x64@0.25.1': - resolution: {integrity: sha512-0IZWLiTyz7nm0xuIs0q1Y3QWJC52R8aSXxe40VUxm6BB1RNmkODtW6LHvWRrGiICulcX7ZvyH6h5fqdLu4gkww==} - engines: {node: '>=18'} - cpu: [x64] - os: [freebsd] - - '@esbuild/linux-arm64@0.25.1': - resolution: {integrity: sha512-jaN3dHi0/DDPelk0nLcXRm1q7DNJpjXy7yWaWvbfkPvI+7XNSc/lDOnCLN7gzsyzgu6qSAmgSvP9oXAhP973uQ==} - engines: {node: '>=18'} - cpu: [arm64] - os: [linux] - - '@esbuild/linux-arm@0.25.1': - resolution: {integrity: sha512-NdKOhS4u7JhDKw9G3cY6sWqFcnLITn6SqivVArbzIaf3cemShqfLGHYMx8Xlm/lBit3/5d7kXvriTUGa5YViuQ==} - engines: {node: '>=18'} - cpu: [arm] - os: [linux] - - '@esbuild/linux-ia32@0.25.1': - resolution: {integrity: sha512-OJykPaF4v8JidKNGz8c/q1lBO44sQNUQtq1KktJXdBLn1hPod5rE/Hko5ugKKZd+D2+o1a9MFGUEIUwO2YfgkQ==} - engines: {node: '>=18'} - cpu: [ia32] - os: [linux] - - '@esbuild/linux-loong64@0.25.1': - resolution: {integrity: sha512-nGfornQj4dzcq5Vp835oM/o21UMlXzn79KobKlcs3Wz9smwiifknLy4xDCLUU0BWp7b/houtdrgUz7nOGnfIYg==} - engines: {node: '>=18'} - cpu: [loong64] - os: [linux] - - '@esbuild/linux-mips64el@0.25.1': - resolution: {integrity: sha512-1osBbPEFYwIE5IVB/0g2X6i1qInZa1aIoj1TdL4AaAb55xIIgbg8Doq6a5BzYWgr+tEcDzYH67XVnTmUzL+nXg==} - engines: {node: '>=18'} - cpu: [mips64el] - os: [linux] - - '@esbuild/linux-ppc64@0.25.1': - resolution: {integrity: sha512-/6VBJOwUf3TdTvJZ82qF3tbLuWsscd7/1w+D9LH0W/SqUgM5/JJD0lrJ1fVIfZsqB6RFmLCe0Xz3fmZc3WtyVg==} - engines: {node: '>=18'} - cpu: [ppc64] - os: [linux] - - '@esbuild/linux-riscv64@0.25.1': - resolution: {integrity: sha512-nSut/Mx5gnilhcq2yIMLMe3Wl4FK5wx/o0QuuCLMtmJn+WeWYoEGDN1ipcN72g1WHsnIbxGXd4i/MF0gTcuAjQ==} - engines: {node: '>=18'} - cpu: [riscv64] - os: [linux] - - '@esbuild/linux-s390x@0.25.1': - resolution: {integrity: sha512-cEECeLlJNfT8kZHqLarDBQso9a27o2Zd2AQ8USAEoGtejOrCYHNtKP8XQhMDJMtthdF4GBmjR2au3x1udADQQQ==} - engines: {node: '>=18'} - cpu: [s390x] - os: [linux] - - '@esbuild/linux-x64@0.25.1': - resolution: {integrity: sha512-xbfUhu/gnvSEg+EGovRc+kjBAkrvtk38RlerAzQxvMzlB4fXpCFCeUAYzJvrnhFtdeyVCDANSjJvOvGYoeKzFA==} - engines: {node: '>=18'} - cpu: [x64] - os: [linux] - - '@esbuild/netbsd-arm64@0.25.1': - resolution: {integrity: sha512-O96poM2XGhLtpTh+s4+nP7YCCAfb4tJNRVZHfIE7dgmax+yMP2WgMd2OecBuaATHKTHsLWHQeuaxMRnCsH8+5g==} - engines: {node: '>=18'} - cpu: [arm64] - os: [netbsd] - - '@esbuild/netbsd-x64@0.25.1': - resolution: {integrity: sha512-X53z6uXip6KFXBQ+Krbx25XHV/NCbzryM6ehOAeAil7X7oa4XIq+394PWGnwaSQ2WRA0KI6PUO6hTO5zeF5ijA==} - engines: {node: '>=18'} - cpu: [x64] - os: [netbsd] - - '@esbuild/openbsd-arm64@0.25.1': - resolution: {integrity: sha512-Na9T3szbXezdzM/Kfs3GcRQNjHzM6GzFBeU1/6IV/npKP5ORtp9zbQjvkDJ47s6BCgaAZnnnu/cY1x342+MvZg==} - engines: {node: '>=18'} - cpu: [arm64] - os: [openbsd] - - '@esbuild/openbsd-x64@0.25.1': - resolution: {integrity: sha512-T3H78X2h1tszfRSf+txbt5aOp/e7TAz3ptVKu9Oyir3IAOFPGV6O9c2naym5TOriy1l0nNf6a4X5UXRZSGX/dw==} - engines: {node: '>=18'} - cpu: [x64] - os: [openbsd] - - '@esbuild/sunos-x64@0.25.1': - resolution: {integrity: sha512-2H3RUvcmULO7dIE5EWJH8eubZAI4xw54H1ilJnRNZdeo8dTADEZ21w6J22XBkXqGJbe0+wnNJtw3UXRoLJnFEg==} - engines: {node: '>=18'} - cpu: [x64] - os: [sunos] - - '@esbuild/win32-arm64@0.25.1': - resolution: {integrity: sha512-GE7XvrdOzrb+yVKB9KsRMq+7a2U/K5Cf/8grVFRAGJmfADr/e/ODQ134RK2/eeHqYV5eQRFxb1hY7Nr15fv1NQ==} - engines: {node: '>=18'} - cpu: [arm64] - os: [win32] - - '@esbuild/win32-ia32@0.25.1': - resolution: {integrity: sha512-uOxSJCIcavSiT6UnBhBzE8wy3n0hOkJsBOzy7HDAuTDE++1DJMRRVCPGisULScHL+a/ZwdXPpXD3IyFKjA7K8A==} - engines: {node: '>=18'} - cpu: [ia32] - os: [win32] - - '@esbuild/win32-x64@0.25.1': - resolution: {integrity: sha512-Y1EQdcfwMSeQN/ujR5VayLOJ1BHaK+ssyk0AEzPjC+t1lITgsnccPqFjb6V+LsTp/9Iov4ysfjxLaGJ9RPtkVg==} - engines: {node: '>=18'} - cpu: [x64] - os: [win32] - - '@microsoft/api-extractor-model@7.30.4': - resolution: {integrity: sha512-RobC0gyVYsd2Fao9MTKOfTdBm41P/bCMUmzS5mQ7/MoAKEqy0FOBph3JOYdq4X4BsEnMEiSHc+0NUNmdzxCpjA==} - - '@microsoft/api-extractor@7.52.1': - resolution: {integrity: sha512-m3I5uAwE05orsu3D1AGyisX5KxsgVXB+U4bWOOaX/Z7Ftp/2Cy41qsNhO6LPvSxHBaapyser5dVorF1t5M6tig==} + '@microsoft/api-extractor-model@7.30.5': + resolution: {integrity: sha512-0ic4rcbcDZHz833RaTZWTGu+NpNgrxVNjVaor0ZDUymfDFzjA/Uuk8hYziIUIOEOSTfmIQqyzVwlzxZxPe7tOA==} + + '@microsoft/api-extractor@7.52.2': + resolution: {integrity: sha512-RX37V5uhBBPUvrrcmIxuQ8TPsohvr6zxo7SsLPOzBYcH9nbjbvtdXrts4cxHCXGOin9JR5ar37qfxtCOuEBTHA==} hasBin: true '@microsoft/tsdoc-config@0.17.1': @@ -186,8 +33,8 @@ packages: '@microsoft/tsdoc@0.15.1': resolution: {integrity: sha512-4aErSrCR/On/e5G2hDP0wjooqDdauzEbIq8hIkIe5pXV0rtWJZvdCEKL0ykZxex+IxIwBp0eGeV48hQN07dXtw==} - '@rushstack/node-core-library@5.12.0': - resolution: {integrity: sha512-QSwwzgzWoil1SCQse+yCHwlhRxNv2dX9siPnAb9zR/UmMhac4mjMrlMZpk64BlCeOFi1kJKgXRkihSwRMbboAQ==} + '@rushstack/node-core-library@5.13.0': + resolution: {integrity: sha512-IGVhy+JgUacAdCGXKUrRhwHMTzqhWwZUI+qEPcdzsb80heOw0QPbhhoVsoiMF7Klp8eYsp7hzpScMXmOa3Uhfg==} peerDependencies: '@types/node': '*' peerDependenciesMeta: @@ -197,22 +44,22 @@ packages: '@rushstack/rig-package@0.5.3': resolution: {integrity: sha512-olzSSjYrvCNxUFZowevC3uz8gvKr3WTpHQ7BkpjtRpA3wK+T0ybep/SRUMfr195gBzJm5gaXw0ZMgjIyHqJUow==} - '@rushstack/terminal@0.15.1': - resolution: {integrity: sha512-3vgJYwumcjoDOXU3IxZfd616lqOdmr8Ezj4OWgJZfhmiBK4Nh7eWcv8sU8N/HdzXcuHDXCRGn/6O2Q75QvaZMA==} + '@rushstack/terminal@0.15.2': + resolution: {integrity: sha512-7Hmc0ysK5077R/IkLS9hYu0QuNafm+TbZbtYVzCMbeOdMjaRboLKrhryjwZSRJGJzu+TV1ON7qZHeqf58XfLpA==} peerDependencies: '@types/node': '*' peerDependenciesMeta: '@types/node': optional: true - '@rushstack/ts-command-line@4.23.6': - resolution: {integrity: sha512-7WepygaF3YPEoToh4MAL/mmHkiIImQq3/uAkQX46kVoKTNOOlCtFGyNnze6OYuWw2o9rxsyrHVfIBKxq/am2RA==} + '@rushstack/ts-command-line@4.23.7': + resolution: {integrity: sha512-Gr9cB7DGe6uz5vq2wdr89WbVDKz0UeuFEn5H2CfWDe7JvjFFaiV15gi6mqDBTbHhHCWS7w8mF1h3BnIfUndqdA==} '@types/argparse@1.0.38': resolution: {integrity: sha512-ebDJ9b0e702Yr7pWgB0jzm+CX4Srzz8RcXtLJDJB+BSccqMa36uyH/zUsSYao5+BD1ytv3k3rPYCq4mAE1hsXA==} - '@types/node@22.13.11': - resolution: {integrity: sha512-iEUCUJoU0i3VnrCmgoWCXttklWcvoCIx4jzcP22fioIVSdTmjgoEvmAO/QPw6TcS9k5FrNgn4w7q5lGOd1CT5g==} + '@types/node@22.13.14': + resolution: {integrity: sha512-Zs/Ollc1SJ8nKUAgc7ivOEdIBM8JAKgrqqUYi2J997JuKO7/tpQC+WCetQ1sypiKCQWHdvdg9wBNpUPEWZae7w==} ajv-draft-04@1.0.0: resolution: {integrity: sha512-mv00Te6nmYbRp5DCwclxtt7yV/joXJPGS7nM+97GdxvuttCOfgI3K4U25zboyeX0O+myI8ERluxQe5wljMmVIw==} @@ -248,11 +95,6 @@ packages: concat-map@0.0.1: resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} - esbuild@0.25.1: - resolution: {integrity: sha512-BGO5LtrGC7vxnqucAe/rmvKdJllfGaYWdyABvyMoXQlfYMb2bbRuReWR5tEGE//4LcNJj9XrkovTqNYRFZHAMQ==} - engines: {node: '>=18'} - hasBin: true - fast-deep-equal@3.1.3: resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} @@ -365,98 +207,23 @@ packages: snapshots: - '@esbuild/aix-ppc64@0.25.1': - optional: true - - '@esbuild/android-arm64@0.25.1': - optional: true - - '@esbuild/android-arm@0.25.1': - optional: true - - '@esbuild/android-x64@0.25.1': - optional: true - - '@esbuild/darwin-arm64@0.25.1': - optional: true - - '@esbuild/darwin-x64@0.25.1': - optional: true - - '@esbuild/freebsd-arm64@0.25.1': - optional: true - - '@esbuild/freebsd-x64@0.25.1': - optional: true - - '@esbuild/linux-arm64@0.25.1': - optional: true - - '@esbuild/linux-arm@0.25.1': - optional: true - - '@esbuild/linux-ia32@0.25.1': - optional: true - - '@esbuild/linux-loong64@0.25.1': - optional: true - - '@esbuild/linux-mips64el@0.25.1': - optional: true - - '@esbuild/linux-ppc64@0.25.1': - optional: true - - '@esbuild/linux-riscv64@0.25.1': - optional: true - - '@esbuild/linux-s390x@0.25.1': - optional: true - - '@esbuild/linux-x64@0.25.1': - optional: true - - '@esbuild/netbsd-arm64@0.25.1': - optional: true - - '@esbuild/netbsd-x64@0.25.1': - optional: true - - '@esbuild/openbsd-arm64@0.25.1': - optional: true - - '@esbuild/openbsd-x64@0.25.1': - optional: true - - '@esbuild/sunos-x64@0.25.1': - optional: true - - '@esbuild/win32-arm64@0.25.1': - optional: true - - '@esbuild/win32-ia32@0.25.1': - optional: true - - '@esbuild/win32-x64@0.25.1': - optional: true - - '@microsoft/api-extractor-model@7.30.4(@types/node@22.13.11)': + '@microsoft/api-extractor-model@7.30.5(@types/node@22.13.14)': dependencies: '@microsoft/tsdoc': 0.15.1 '@microsoft/tsdoc-config': 0.17.1 - '@rushstack/node-core-library': 5.12.0(@types/node@22.13.11) + '@rushstack/node-core-library': 5.13.0(@types/node@22.13.14) transitivePeerDependencies: - '@types/node' - '@microsoft/api-extractor@7.52.1(@types/node@22.13.11)': + '@microsoft/api-extractor@7.52.2(@types/node@22.13.14)': dependencies: - '@microsoft/api-extractor-model': 7.30.4(@types/node@22.13.11) + '@microsoft/api-extractor-model': 7.30.5(@types/node@22.13.14) '@microsoft/tsdoc': 0.15.1 '@microsoft/tsdoc-config': 0.17.1 - '@rushstack/node-core-library': 5.12.0(@types/node@22.13.11) + '@rushstack/node-core-library': 5.13.0(@types/node@22.13.14) '@rushstack/rig-package': 0.5.3 - '@rushstack/terminal': 0.15.1(@types/node@22.13.11) - '@rushstack/ts-command-line': 4.23.6(@types/node@22.13.11) + '@rushstack/terminal': 0.15.2(@types/node@22.13.14) + '@rushstack/ts-command-line': 4.23.7(@types/node@22.13.14) lodash: 4.17.21 minimatch: 3.0.8 resolve: 1.22.10 @@ -475,7 +242,7 @@ snapshots: '@microsoft/tsdoc@0.15.1': {} - '@rushstack/node-core-library@5.12.0(@types/node@22.13.11)': + '@rushstack/node-core-library@5.13.0(@types/node@22.13.14)': dependencies: ajv: 8.13.0 ajv-draft-04: 1.0.0(ajv@8.13.0) @@ -486,23 +253,23 @@ snapshots: resolve: 1.22.10 semver: 7.5.4 optionalDependencies: - '@types/node': 22.13.11 + '@types/node': 22.13.14 '@rushstack/rig-package@0.5.3': dependencies: resolve: 1.22.10 strip-json-comments: 3.1.1 - '@rushstack/terminal@0.15.1(@types/node@22.13.11)': + '@rushstack/terminal@0.15.2(@types/node@22.13.14)': dependencies: - '@rushstack/node-core-library': 5.12.0(@types/node@22.13.11) + '@rushstack/node-core-library': 5.13.0(@types/node@22.13.14) supports-color: 8.1.1 optionalDependencies: - '@types/node': 22.13.11 + '@types/node': 22.13.14 - '@rushstack/ts-command-line@4.23.6(@types/node@22.13.11)': + '@rushstack/ts-command-line@4.23.7(@types/node@22.13.14)': dependencies: - '@rushstack/terminal': 0.15.1(@types/node@22.13.11) + '@rushstack/terminal': 0.15.2(@types/node@22.13.14) '@types/argparse': 1.0.38 argparse: 1.0.10 string-argv: 0.3.2 @@ -511,7 +278,7 @@ snapshots: '@types/argparse@1.0.38': {} - '@types/node@22.13.11': + '@types/node@22.13.14': dependencies: undici-types: 6.20.0 @@ -550,34 +317,6 @@ snapshots: concat-map@0.0.1: {} - esbuild@0.25.1: - optionalDependencies: - '@esbuild/aix-ppc64': 0.25.1 - '@esbuild/android-arm': 0.25.1 - '@esbuild/android-arm64': 0.25.1 - '@esbuild/android-x64': 0.25.1 - '@esbuild/darwin-arm64': 0.25.1 - '@esbuild/darwin-x64': 0.25.1 - '@esbuild/freebsd-arm64': 0.25.1 - '@esbuild/freebsd-x64': 0.25.1 - '@esbuild/linux-arm': 0.25.1 - '@esbuild/linux-arm64': 0.25.1 - '@esbuild/linux-ia32': 0.25.1 - '@esbuild/linux-loong64': 0.25.1 - '@esbuild/linux-mips64el': 0.25.1 - '@esbuild/linux-ppc64': 0.25.1 - '@esbuild/linux-riscv64': 0.25.1 - '@esbuild/linux-s390x': 0.25.1 - '@esbuild/linux-x64': 0.25.1 - '@esbuild/netbsd-arm64': 0.25.1 - '@esbuild/netbsd-x64': 0.25.1 - '@esbuild/openbsd-arm64': 0.25.1 - '@esbuild/openbsd-x64': 0.25.1 - '@esbuild/sunos-x64': 0.25.1 - '@esbuild/win32-arm64': 0.25.1 - '@esbuild/win32-ia32': 0.25.1 - '@esbuild/win32-x64': 0.25.1 - fast-deep-equal@3.1.3: {} fs-extra@11.3.0: diff --git a/bazel/spec-bundling/index_rjs.bzl b/bazel/spec-bundling/index_rjs.bzl index ec23c9632..c3773990b 100644 --- a/bazel/spec-bundling/index_rjs.bzl +++ b/bazel/spec-bundling/index_rjs.bzl @@ -1,5 +1,5 @@ +load("@aspect_rules_esbuild//esbuild:defs.bzl", "esbuild") load("@devinfra//bazel/spec-bundling:spec-entrypoint.bzl", "spec_entrypoint") -load("@devinfra_npm//bazel:esbuild/package_json.bzl", esbuild = "bin") def spec_bundle(name, deps, bootstrap = [], testonly = True, **kwargs): spec_entrypoint( @@ -9,7 +9,7 @@ def spec_bundle(name, deps, bootstrap = [], testonly = True, **kwargs): testonly = testonly, ) - esbuild.esbuild( + esbuild( name = name, # Note: `deps` are added here to automatically collect transitive NPM # sources etc. and make them available for bundling. @@ -17,21 +17,25 @@ def spec_bundle(name, deps, bootstrap = [], testonly = True, **kwargs): ":%s_entrypoint" % name, ], testonly = testonly, - outs = [ - "%s_spec_bundle.spec.js" % name, - "%s_spec_bundle.spec.js.map" % name, - ], - args = [ - "--format=iife", - "--bundle", - "--resolve-extensions=.mjs,.js", - "--minify", - "--sourcemap=external", - "--platform=node", - "--outfile=%s/%s_spec_bundle.spec.js " % (native.package_name(), name), - "%s/%s_entrypoint.mjs" % (native.package_name(), name), - ], - progress_message = "Creating spec-bundle", - silent_on_success = True, + bundle = True, + format = "iife", + minify = True, + sourcemap = "external", + platform = "node", + entry_point = ":%s_entrypoint" % name, + output = "%s.spec.js" % name, + **kwargs + ) + +def spec_bundle_amd(name, workspace_name, **kwargs): + amd_name = "%s/%s/%s" % (workspace_name, native.package_name(), name + ".spec") + + spec_bundle( + name, + config = { + "globalName": "__exports", + "banner": {"js": "define(\"%s\", [], function() {" % amd_name}, + "footer": {"js": "return __exports;})"}, + }, **kwargs )