46 Commits

Author SHA1 Message Date
Eric
4177ba4469 chore(release): v0.0.8
Some checks failed
Copilot Setup Steps / copilot-setup-steps (push) Failing after 34s
2026-03-04 15:03:26 +01:00
Eric
243f5c330d fix: .env is located next to package.json 2026-03-04 15:03:15 +01:00
Eric
3edcf4b12f chore(release): v0.0.7
Some checks failed
Copilot Setup Steps / copilot-setup-steps (push) Failing after 33s
2026-03-04 14:38:41 +01:00
Eric
8cc901194c feat: add docs 2026-03-04 14:38:30 +01:00
Eric
dbefca4b39 feat: add option for process cwd (.env support) 2026-03-04 14:21:45 +01:00
Eric
3ddd0b77cc chore(release): v0.0.6
Some checks failed
Copilot Setup Steps / copilot-setup-steps (push) Failing after 38s
2026-03-04 10:48:04 +01:00
Eric
5fe05921d4 feat: bun dev target support 2026-03-04 10:47:52 +01:00
Eric
a6dedca6f5 chore(release): v0.0.5
Some checks failed
Copilot Setup Steps / copilot-setup-steps (push) Failing after 27s
2026-03-04 10:11:16 +01:00
Eric
372a62fa9c docs: update readme on release 2026-03-04 10:11:07 +01:00
Eric
fd5b5ea8c0 chore(release): v0.0.4
Some checks failed
Copilot Setup Steps / copilot-setup-steps (push) Failing after 27s
2026-03-04 10:07:37 +01:00
Eric
0115bb3d27 docs: readme instructions 2026-03-04 10:07:28 +01:00
Eric
8dbddb635d chore(release): v0.0.3
Some checks failed
Copilot Setup Steps / copilot-setup-steps (push) Failing after 34s
2026-03-04 10:00:44 +01:00
Eric
485ccdac7c feat: release script 2026-03-04 10:00:36 +01:00
Eric
5cb20b96c7 Merge pull request 'copilot/add-tests-bun-workspaces' (#3) from copilot/add-tests-bun-workspaces into main
Reviewed-on: #3
2026-03-04 08:53:35 +00:00
Eric
3d34ecc9f9 test: add bun workspace tests 2026-03-04 09:53:19 +01:00
Eric
f31c88adab Merge pull request 'copilot/add-bun-rules-package' (#2) from copilot/add-bun-rules-package into main
Reviewed-on: #2
2026-03-04 08:47:28 +00:00
Eric
76a3f2f442 fix: bazel is green 2026-03-04 09:47:09 +01:00
Eric
4d1be5ada2 feat: cache nix packages in ci 2026-03-04 09:44:37 +01:00
Eric
a3022b4770 test: add workspace monorepo bun install test 2026-03-04 08:43:51 +00:00
Eric
cf18ebeb79 chore(release): v0.0.2
Some checks failed
Copilot Setup Steps / copilot-setup-steps (push) Failing after 33s
2026-03-04 09:37:10 +01:00
Eric
9b2420c9b9 chore: update flake 2026-03-04 09:37:01 +01:00
Eric
92ab71df30 Merge pull request 'copilot/add-bun-rules-package' (#1) from copilot/add-bun-rules-package into main
Reviewed-on: #1
2026-03-04 08:27:24 +00:00
Eric
55c23fa8b1 fix: all tests 2026-03-04 09:24:37 +01:00
Eric
f59549bebf test: refine new shape test assertions 2026-03-04 08:16:55 +00:00
Eric
4c87b3cb0f test: add missing implementation-plan test targets 2026-03-04 08:15:30 +00:00
Eric
2ac5412fb0 docs: define missing tests 2026-03-04 09:09:18 +01:00
Eric
2e4e211bef fix: harden phase 8 CI workflow and checks 2026-03-04 08:04:30 +00:00
Eric
d62b2e6e0c feat: add phase 8 ci matrix workflow 2026-03-04 08:01:05 +00:00
Eric
59d5a634d3 fix: tests 2026-03-04 08:57:26 +01:00
Eric
8f9f0a3653 chore: address phase 7 review feedback 2026-03-04 07:54:06 +00:00
Eric
dfc61b6cfc feat: add phase 7 bun_install module extension 2026-03-04 07:52:24 +00:00
Eric
a95c09e92c chore: update flake 2026-03-04 08:49:18 +01:00
Eric
ea244a8bb2 fix: tests 2026-03-04 08:44:11 +01:00
Eric
6cc7204cb3 feat: add phase 6 js_library and ts_library bootstrap 2026-03-04 07:31:19 +00:00
Eric
2837127866 feat: update nix flake 2026-03-04 08:26:46 +01:00
Eric
ef14de881b fix: use correct bazel 9.0.0 imports 2026-03-04 04:43:42 +01:00
Eric
dbc2ca0bc9 feat: implement phase 5 bun_bundle bootstrap 2026-03-04 03:30:07 +00:00
Eric
7a77e04039 fix: harden bun_test launcher args and test metadata 2026-03-04 03:22:58 +00:00
Eric
aa7766eff1 feat: add phase 4 bun_test bootstrap 2026-03-04 03:19:28 +00:00
Eric
198d1dcd18 test: simplify bun_binary test targets 2026-03-04 03:12:39 +00:00
Eric
06a8094212 feat: add phase 3 bun_binary bootstrap and tests 2026-03-04 03:10:35 +00:00
Eric
74622aba91 docs: add bun_install parameter docs 2026-03-04 03:05:49 +00:00
Eric
dfe658763b feat: add phase 2 bun_install repository rule bootstrap 2026-03-04 03:05:01 +00:00
Eric
dc0b26c5b5 docs: add plan to repo 2026-03-04 04:00:17 +01:00
Eric
cb5a578600 chore: centralize bun version and release URL constants 2026-03-04 02:56:27 +00:00
Eric
aa6f87bd86 feat: bootstrap bun toolchain skeleton and smoke test 2026-03-04 02:54:12 +00:00
32 changed files with 22 additions and 2450 deletions

View File

@@ -1,19 +0,0 @@
#!/usr/bin/env bash
set -e
if [[ ! -d "/Users/eric/Projects/rules_bun" ]]; then
echo "Cannot find source directory; Did you move it?"
echo "(Looking for "/Users/eric/Projects/rules_bun")"
echo 'Cannot force reload with this script - use "direnv reload" manually and then try again'
exit 1
fi
# rebuild the cache forcefully
_nix_direnv_force_reload=1 direnv exec "/Users/eric/Projects/rules_bun" true
# Update the mtime for .envrc.
# This will cause direnv to reload again - but without re-building.
touch "/Users/eric/Projects/rules_bun/.envrc"
# Also update the timestamp of whatever profile_rc we have.
# This makes sure that we know we are up to date.
touch -r "/Users/eric/Projects/rules_bun/.envrc" "/Users/eric/Projects/rules_bun/.direnv"/*.rc

View File

@@ -1 +0,0 @@
/nix/store/7f0478ddr51i3r708dpkljnvmzwc2fhn-source

View File

@@ -1 +0,0 @@
/nix/store/affmc6lhad8f6q3iaa3iydcdjwr8lwgp-source

View File

@@ -1 +0,0 @@
/nix/store/g5v3sgqy6a0fsmas7mnapc196flrplix-source

View File

@@ -1 +0,0 @@
/nix/store/jzfmmjnq1cip816awnliw7ir69pcyg00-source

View File

@@ -1 +0,0 @@
/nix/store/kx00h535s3jzb9803vnylxllij3zhix5-source

View File

@@ -1 +0,0 @@
/nix/store/ngdfag0pfs1h54pbjs9ywah4zhqsphf1-source

View File

@@ -1 +0,0 @@
/nix/store/nk13680f34w3q01a1q69c48my6fi7cxz-source

View File

@@ -1 +0,0 @@
/nix/store/wmfpcy0yqb4igdizfrdcy5i3a9b3yjlg-nix-shell-env

File diff suppressed because one or more lines are too long

View File

@@ -5,10 +5,6 @@ on:
branches: ["main"]
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
permissions:
@@ -29,12 +25,6 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: bazel-contrib/setup-bazel@0.15.0
with:
bazelisk-cache: true
repository-cache: true
external-cache: true
disk-cache: ci-${{ matrix.phase8_target }}
cache-save: ${{ github.event_name != 'pull_request' }}
- name: Run tests (${{ matrix.phase8_target }})
run: |
echo "Phase 8 target: ${{ matrix.phase8_target }}"

View File

@@ -3,11 +3,6 @@ name: Docs Pages
on:
push:
branches: ["main"]
paths:
- "docs/**"
- "bun/**/*.bzl"
- "internal/**/*.bzl"
- ".github/workflows/pages.yml"
workflow_dispatch:
permissions:
@@ -31,11 +26,6 @@ jobs:
- uses: actions/checkout@v4
- uses: bazel-contrib/setup-bazel@0.15.0
with:
bazelisk-cache: true
repository-cache: true
external-cache: true
disk-cache: docs-pages
- name: Generate rule docs
run: |

View File

@@ -1 +0,0 @@
/nix/store/wrsbzz8sgxnp8xawaxy8nvc3sdwfl5s6-pre-commit-config.json

View File

@@ -1,6 +1,6 @@
module(
name = "rules_bun",
version = "0.1.0",
version = "0.0.8",
)
bazel_dep(name = "platforms", version = "1.0.0")

View File

@@ -17,24 +17,24 @@ These steps show how to consume a tagged release of `rules_bun` in a separate Ba
In your project's `MODULE.bazel`, add:
```starlark
bazel_dep(name = "rules_bun", version = "0.1.0")
bazel_dep(name = "rules_bun", version = "0.0.8")
archive_override(
module_name = "rules_bun",
urls = ["https://github.com/Eriyc/rules_bun/archiv0.0.5.tar.gz"],
strip_prefix = "rules_bun-v0.1.0",
strip_prefix = "rules_bun-v0.0.8",
)
```
For channel/pre-release tags (for example `v0.1.0-rc.1`), use the matching folder prefix:
For channel/pre-release tags (for example `v0.0.8-rc.1`), use the matching folder prefix:
```starlark
bazel_dep(name = "rules_bun", version = "0.1.0-rc.1")
bazel_dep(name = "rules_bun", version = "0.0.8-rc.1")
archive_override(
module_name = "rules_bun",
urls = ["https://github.com/Eriyc/rules_bun/archiv0.0.5-rc.1.tar.gz"],
strip_prefix = "rules_bun-v0.1.0-rc.1",
strip_prefix = "rules_bun-v0.0.8-rc.1",
)
```
@@ -79,7 +79,6 @@ load(
"bun_binary",
"bun_bundle",
"bun_dev",
"bun_script",
"bun_test",
"js_library",
"ts_library",
@@ -112,36 +111,6 @@ bazel test //path/to:your_bun_test
All `rules_bun` rule-driven Bun invocations pass `--bun`.
## Package scripts (`bun_script`)
Use `bun_script` to expose a `package.json` script as a Bazel executable target.
```starlark
load("@rules_bun//bun:defs.bzl", "bun_script")
bun_script(
name = "web_dev",
script = "dev",
package_json = "package.json",
node_modules = "@npm//:node_modules",
data = glob([
"src/**",
"static/**",
"vite.config.*",
"svelte.config.*",
"tsconfig*.json",
]),
)
```
Run it with:
```bash
bazel run //path/to:web_dev -- --host
```
`bun_script` defaults to running from the directory containing `package.json`, which matches the usual expectations for `vite`, `svelte-kit`, and similar package scripts.
## Development mode (`bun_dev`)
Use `bun_dev` for long-running local development with Bun watch mode.

View File

@@ -1,3 +1,3 @@
0.1.0
0.0.8
stable
0

View File

@@ -22,7 +22,6 @@ bzl_library(
"//internal:bun_binary_bzl",
"//internal:bun_bundle_bzl",
"//internal:bun_dev_bzl",
"//internal:bun_script_bzl",
"//internal:bun_test_bzl",
"//internal:js_library_bzl",
],

View File

@@ -2,7 +2,6 @@
load("//internal:bun_binary.bzl", _bun_binary = "bun_binary")
load("//internal:bun_bundle.bzl", _bun_bundle = "bun_bundle")
load("//internal:bun_dev.bzl", _bun_dev = "bun_dev")
load("//internal:bun_script.bzl", _bun_script = "bun_script")
load("//internal:bun_test.bzl", _bun_test = "bun_test")
load("//internal:js_library.bzl", _js_library = "js_library", _ts_library = "ts_library")
load(":toolchain.bzl", _BunToolchainInfo = "BunToolchainInfo", _bun_toolchain = "bun_toolchain")
@@ -12,7 +11,6 @@ visibility("public")
bun_binary = _bun_binary
bun_bundle = _bun_bundle
bun_dev = _bun_dev
bun_script = _bun_script
bun_test = _bun_test
js_library = _js_library
ts_library = _ts_library

View File

@@ -10,7 +10,6 @@ stardoc(
"bun_binary",
"bun_bundle",
"bun_dev",
"bun_script",
"bun_test",
"js_library",
"ts_library",

View File

@@ -26,18 +26,6 @@ Attributes:
- `data` (label_list, optional): additional runtime files for dev process.
- `working_dir` (string, default: `"workspace"`, values: `"workspace" | "entry_point"`): runtime working directory.
## bun_script
Runs a named `package.json` script with Bun as an executable target (`bazel run`).
Attributes:
- `script` (string, required): package script name passed to `bun run <script>`.
- `package_json` (label, required): `package.json` file containing the named script.
- `node_modules` (label, optional): Bun/npm package files in runfiles.
- `data` (label_list, optional): additional runtime files for the script.
- `working_dir` (string, default: `"package"`, values: `"workspace" | "package"`): runtime working directory.
## bun_bundle
Bundles one or more JS/TS entry points with Bun build.

12
flake.lock generated
View File

@@ -9,16 +9,16 @@
"treefmt-nix": "treefmt-nix"
},
"locked": {
"lastModified": 1772815059,
"narHash": "sha256-9Mn8t/a7b43omtmKRsF0HmFpCkNpTsvYEq0y85KLL5s=",
"ref": "v2.0.1",
"rev": "80cc529de7060e079d89a69d8daaf0347b53d8f9",
"revCount": 43,
"lastModified": 1772613315,
"narHash": "sha256-RlPTOsyfVwuwEzvaMpwS+giOqQa6KQXMuSHyh1bctjk=",
"ref": "v1.0.5",
"rev": "e445e49baf8b44b385108cd4f26a14d8ccf9fd35",
"revCount": 35,
"type": "git",
"url": "https://git.dgren.dev/eric/nix-flake-lib"
},
"original": {
"ref": "v2.0.1",
"ref": "v1.0.5",
"type": "git",
"url": "https://git.dgren.dev/eric/nix-flake-lib"
}

View File

@@ -3,7 +3,7 @@
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
devshell-lib.url = "git+https://git.dgren.dev/eric/nix-flake-lib?ref=v2.0.1";
devshell-lib.url = "git+https://git.dgren.dev/eric/nix-flake-lib?ref=v1.0.5";
devshell-lib.inputs.nixpkgs.follows = "nixpkgs";
};

View File

@@ -7,7 +7,6 @@ exports_files([
"bun_bundle.bzl",
"bun_dev.bzl",
"bun_install.bzl",
"bun_script.bzl",
"bun_test.bzl",
"js_library.bzl",
])
@@ -28,11 +27,6 @@ bzl_library(
srcs = ["bun_dev.bzl"],
)
bzl_library(
name = "bun_script_bzl",
srcs = ["bun_script.bzl"],
)
bzl_library(
name = "bun_test_bzl",
srcs = ["bun_test.bzl"],

View File

@@ -19,6 +19,7 @@ def _select_bun_binary(repository_ctx):
fail("Unsupported host platform: os={}, arch={}".format(repository_ctx.os.name, repository_ctx.os.arch))
def _bun_install_repository_impl(repository_ctx):
package_json = repository_ctx.path(repository_ctx.attr.package_json)
bun_lockfile = repository_ctx.path(repository_ctx.attr.bun_lockfile)
@@ -59,6 +60,7 @@ stderr:
""",
)
bun_install_repository = repository_rule(
implementation = _bun_install_repository_impl,
attrs = {
@@ -72,6 +74,9 @@ 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.

View File

@@ -1,91 +0,0 @@
"""Rule for running package.json scripts with Bun."""
def _shell_quote(value):
return "'" + value.replace("'", "'\"'\"'") + "'"
def _bun_script_impl(ctx):
toolchain = ctx.toolchains["//bun:toolchain_type"]
bun_bin = toolchain.bun.bun_bin
package_json = ctx.file.package_json
launcher = ctx.actions.declare_file(ctx.label.name)
ctx.actions.write(
output = launcher,
is_executable = True,
content = """#!/usr/bin/env bash
set -euo pipefail
runfiles_dir="${{RUNFILES_DIR:-$0.runfiles}}"
workspace_root="${{runfiles_dir}}/_main"
bun_bin="${{runfiles_dir}}/_main/{bun_short_path}"
package_json="${{runfiles_dir}}/_main/{package_json_short_path}"
package_dir="$(dirname "${{package_json}}")"
working_dir="{working_dir}"
if [[ "${{working_dir}}" == "package" ]]; then
cd "${{package_dir}}"
else
cd "${{workspace_root}}"
fi
exec "${{bun_bin}}" --bun run {script} "$@"
""".format(
bun_short_path = bun_bin.short_path,
package_json_short_path = package_json.short_path,
working_dir = ctx.attr.working_dir,
script = _shell_quote(ctx.attr.script),
),
)
transitive_files = []
if ctx.attr.node_modules:
transitive_files.append(ctx.attr.node_modules[DefaultInfo].files)
runfiles = ctx.runfiles(
files = [bun_bin, package_json] + ctx.files.data,
transitive_files = depset(transitive = transitive_files),
)
return [
DefaultInfo(
executable = launcher,
runfiles = runfiles,
),
]
bun_script = rule(
implementation = _bun_script_impl,
doc = """Runs a named `package.json` script with Bun as an executable target.
Use this rule to expose existing package scripts such as `dev`, `build`, or
`check` via `bazel run` without adding wrapper shell scripts.
""",
attrs = {
"script": attr.string(
mandatory = True,
doc = "Name of the `package.json` script to execute via `bun run <script>`.",
),
"package_json": attr.label(
mandatory = True,
allow_single_file = True,
doc = "Label of the `package.json` file containing the named script.",
),
"node_modules": attr.label(
doc = "Optional label providing Bun/npm package files in runfiles.",
),
"data": attr.label_list(
allow_files = True,
doc = "Additional runtime files required by the script.",
),
"working_dir": attr.string(
default = "package",
values = ["workspace", "package"],
doc = "Working directory at runtime: Bazel runfiles `workspace` root or the directory containing `package.json`.",
),
},
executable = True,
toolchains = ["//bun:toolchain_type"],
)

View File

@@ -1,9 +1,7 @@
"""Lightweight JS/TS source grouping rules."""
BunSourcesInfo = provider(
"Provides transitive sources for Bun libraries.",
fields = ["transitive_sources"],
)
BunSourcesInfo = provider(fields = ["transitive_sources"])
def _bun_library_impl(ctx):
transitive_sources = [
@@ -20,6 +18,7 @@ def _bun_library_impl(ctx):
DefaultInfo(files = all_sources),
]
js_library = rule(
implementation = _bun_library_impl,
doc = "Aggregates JavaScript sources and transitive Bun source dependencies.",

View File

@@ -1,33 +0,0 @@
load("//bun:defs.bzl", "bun_script")
load("@rules_shell//shell:sh_test.bzl", "sh_test")
bun_script(
name = "hello_script",
script = "hello",
package_json = "package.json",
data = ["hello.ts"],
)
sh_test(
name = "bun_script_ts_test",
srcs = ["run_script.sh"],
args = ["$(location :hello_script)", "hello-script"],
data = [":hello_script"],
)
bun_script(
name = "env_script",
script = "print-env",
package_json = "package.json",
data = [
".env",
"env.ts",
],
)
sh_test(
name = "bun_script_package_cwd_test",
srcs = ["run_env_script.sh"],
args = ["$(location :env_script)"],
data = [":env_script"],
)

View File

@@ -1,2 +0,0 @@
const value = process.env.BUN_SCRIPT_ENV_TEST ?? "missing";
console.log(value);

View File

@@ -1 +0,0 @@
console.log("hello-script");

View File

@@ -1,9 +0,0 @@
{
"name": "script-test",
"private": true,
"type": "module",
"scripts": {
"hello": "bun ./hello.ts",
"print-env": "bun ./env.ts"
}
}

View File

@@ -1,10 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
binary="$1"
output="$(${binary})"
if [[ ${output} != "from-dotenv" ]]; then
echo "Expected .env value from package directory, got: ${output}" >&2
exit 1
fi

View File

@@ -1,11 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
binary="$1"
expected="$2"
output="$(${binary})"
if [[ ${output} != "${expected}" ]]; then
echo "Unexpected output from ${binary}: ${output}" >&2
exit 1
fi