copilot/add-bun-rules-package #1
@@ -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`)
|
||||
|
||||
@@ -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")
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
||||
load("//internal:bun_install.bzl", _bun_install_repository = "_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(default = "node_modules"),
|
||||
"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},
|
||||
)
|
||||
|
||||
8
tests/install_extension_test/BUILD.bazel
Normal file
8
tests/install_extension_test/BUILD.bazel
Normal 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"],
|
||||
)
|
||||
9
tests/install_extension_test/extension_shape_test.sh
Executable file
9
tests/install_extension_test/extension_shape_test.sh
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
extension_file="$1"
|
||||
|
||||
grep -q 'bun_install = module_extension(' "${extension_file}"
|
||||
grep -q 'tag_classes = {"install": _install}' "${extension_file}"
|
||||
grep -q '"package_json": attr.string(mandatory = True)' "${extension_file}"
|
||||
grep -q '"bun_lockfile": attr.string(mandatory = True)' "${extension_file}"
|
||||
Reference in New Issue
Block a user