3 Commits

Author SHA1 Message Date
eric
2a24b83d2f fix: tests 2026-03-04 08:57:26 +01:00
copilot-swe-agent[bot]
36c1beb4d7 chore: address phase 7 review feedback
Co-authored-by: Eriyc <50216491+Eriyc@users.noreply.github.com>
2026-03-04 07:54:06 +00:00
copilot-swe-agent[bot]
8cfc9af83d feat: add phase 7 bun_install module extension
Co-authored-by: Eriyc <50216491+Eriyc@users.noreply.github.com>
2026-03-04 07:52:24 +00:00
8 changed files with 58 additions and 4 deletions

1
.bazelignore Normal file
View File

@@ -0,0 +1 @@
.direnv

2
MODULE.bazel.lock generated
View File

@@ -189,7 +189,7 @@
"moduleExtensions": {
"//bun:extensions.bzl%bun": {
"general": {
"bzlTransitiveDigest": "OnZvc44B8aCFH7E+udHBoIoIkL0AeKA27+2lmg/S15Q=",
"bzlTransitiveDigest": "Q0uQOwFAgAU+etePCZ4TUDO+adLX7Z0EmRLaEsKgncw=",
"usagesDigest": "qk1PDh3WICa0VONYKXJLsmWCesNJxz3Jkb/aH/voIeI=",
"recordedInputs": [
"REPO_MAPPING:,bazel_tools bazel_tools"

View File

@@ -40,3 +40,8 @@ Phase 6 bootstrap is in place:
- Source grouping rules `js_library` / `ts_library` (`/internal/js_library.bzl`)
- Transitive `deps` propagation wired into `bun_bundle` and `bun_test`
- Focused dependency-propagation tests (`//tests/library_test:all`)
Phase 7 bootstrap is in place:
- Bzlmod `bun_install` module extension (`/bun/extensions.bzl`) using Bazel 9-compatible extension/tag syntax
- Focused module-extension shape test (`//tests/install_extension_test:all`)

View File

@@ -1,7 +1,10 @@
load(":toolchain.bzl", "bun_toolchain")
load(":version.bzl", "BUN_VERSION")
exports_files(["defs.bzl"])
exports_files([
"defs.bzl",
"extensions.bzl",
])
toolchain_type(name = "toolchain_type")

View File

@@ -1,4 +1,5 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("//internal:bun_install.bzl", "bun_install_repository")
load(":version.bzl", "BUN_VERSION")
_BUN_ARCHIVES = {
@@ -53,3 +54,27 @@ filegroup(
bun = module_extension(
implementation = _bun_repos_impl,
)
_install = tag_class(
attrs = {
"name": attr.string(mandatory = True),
"package_json": attr.string(mandatory = True),
"bun_lockfile": attr.string(mandatory = True),
},
)
def _bun_install_impl(ctx):
for mod in ctx.modules:
for install in mod.tags.install:
bun_install_repository(
name = install.name,
package_json = install.package_json,
bun_lockfile = install.bun_lockfile,
)
bun_install = module_extension(
implementation = _bun_install_impl,
tag_classes = {"install": _install},
)

View File

@@ -61,7 +61,7 @@ stderr:
)
_bun_install_repository = repository_rule(
bun_install_repository = repository_rule(
implementation = _bun_install_repository_impl,
attrs = {
"package_json": attr.label(mandatory = True, allow_single_file = True),
@@ -74,6 +74,8 @@ _bun_install_repository = repository_rule(
},
)
_bun_install_repository = bun_install_repository
def bun_install(name, package_json, bun_lockfile):
"""Create an external repository containing installed node_modules.
@@ -91,7 +93,7 @@ def bun_install(name, package_json, bun_lockfile):
)
"""
_bun_install_repository(
bun_install_repository(
name = name,
package_json = package_json,
bun_lockfile = bun_lockfile,

View File

@@ -0,0 +1,8 @@
load("@rules_shell//shell:sh_test.bzl", "sh_test")
sh_test(
name = "bun_install_extension_shape_test",
srcs = ["extension_shape_test.sh"],
args = ["$(location //bun:extensions.bzl)"],
data = ["//bun:extensions.bzl"],
)

View File

@@ -0,0 +1,10 @@
#!/usr/bin/env bash
set -euo pipefail
extension_file="$1"
grep -Eq 'bun_install[[:space:]]*=[[:space:]]*module_extension\(' "${extension_file}"
grep -Eq 'tag_classes[[:space:]]*=[[:space:]]*\{"install":[[:space:]]*_install\}' "${extension_file}"
grep -Eq '"name":[[:space:]]*attr\.string\(mandatory[[:space:]]*=[[:space:]]*True\)' "${extension_file}"
grep -Eq '"package_json":[[:space:]]*attr\.string\(mandatory[[:space:]]*=[[:space:]]*True\)' "${extension_file}"
grep -Eq '"bun_lockfile":[[:space:]]*attr\.string\(mandatory[[:space:]]*=[[:space:]]*True\)' "${extension_file}"