diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index 41c5815..c180aff 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -34,8 +34,9 @@ "https://bcr.bazel.build/modules/bazel_features/1.3.0/MODULE.bazel": "cdcafe83ec318cda34e02948e81d790aab8df7a929cec6f6969f13a489ccecd9", "https://bcr.bazel.build/modules/bazel_features/1.30.0/MODULE.bazel": "a14b62d05969a293b80257e72e597c2da7f717e1e69fa8b339703ed6731bec87", "https://bcr.bazel.build/modules/bazel_features/1.33.0/MODULE.bazel": "8b8dc9d2a4c88609409c3191165bccec0e4cb044cd7a72ccbe826583303459f6", - "https://bcr.bazel.build/modules/bazel_features/1.33.0/source.json": "13617db3930328c2cd2807a0f13d52ca870ac05f96db9668655113265147b2a6", "https://bcr.bazel.build/modules/bazel_features/1.4.1/MODULE.bazel": "e45b6bb2350aff3e442ae1111c555e27eac1d915e77775f6fdc4b351b758b5d7", + "https://bcr.bazel.build/modules/bazel_features/1.42.1/MODULE.bazel": "275a59b5406ff18c01739860aa70ad7ccb3cfb474579411decca11c93b951080", + "https://bcr.bazel.build/modules/bazel_features/1.42.1/source.json": "fcd4396b2df85f64f2b3bb436ad870793ecf39180f1d796f913cc9276d355309", "https://bcr.bazel.build/modules/bazel_features/1.9.1/MODULE.bazel": "8f679097876a9b609ad1f60249c49d68bfab783dd9be012faf9d82547b14815a", "https://bcr.bazel.build/modules/bazel_skylib/1.0.3/MODULE.bazel": "bcb0fd896384802d1ad283b4e4eb4d718eebd8cb820b0a2c3a347fb971afd9d8", "https://bcr.bazel.build/modules/bazel_skylib/1.1.1/MODULE.bazel": "1add3e7d93ff2e6998f9e118022c84d163917d912f5afafb3058e3d2f1545b5e", @@ -51,8 +52,8 @@ "https://bcr.bazel.build/modules/bazel_skylib/1.8.1/MODULE.bazel": "88ade7293becda963e0e3ea33e7d54d3425127e0a326e0d17da085a5f1f03ff6", "https://bcr.bazel.build/modules/bazel_skylib/1.8.2/MODULE.bazel": "69ad6927098316848b34a9142bcc975e018ba27f08c4ff403f50c1b6e646ca67", "https://bcr.bazel.build/modules/bazel_skylib/1.8.2/source.json": "34a3c8bcf233b835eb74be9d628899bb32999d3e0eadef1947a0a562a2b16ffb", - "https://bcr.bazel.build/modules/buildozer/8.2.1/MODULE.bazel": "61e9433c574c2bd9519cad7fa66b9c1d2b8e8d5f3ae5d6528a2c2d26e68d874d", - "https://bcr.bazel.build/modules/buildozer/8.2.1/source.json": "7c33f6a26ee0216f85544b4bca5e9044579e0219b6898dd653f5fb449cf2e484", + "https://bcr.bazel.build/modules/buildozer/8.5.1/MODULE.bazel": "a35d9561b3fc5b18797c330793e99e3b834a473d5fbd3d7d7634aafc9bdb6f8f", + "https://bcr.bazel.build/modules/buildozer/8.5.1/source.json": "e3386e6ff4529f2442800dee47ad28d3e6487f36a1f75ae39ae56c70f0cd2fbd", "https://bcr.bazel.build/modules/google_benchmark/1.8.2/MODULE.bazel": "a70cf1bba851000ba93b58ae2f6d76490a9feb74192e57ab8e8ff13c34ec50cb", "https://bcr.bazel.build/modules/googletest/1.11.0/MODULE.bazel": "3a83f095183f66345ca86aa13c58b59f9f94a2f81999c093d4eeaa2d262d12f4", "https://bcr.bazel.build/modules/googletest/1.14.0.bcr.1/MODULE.bazel": "22c31a561553727960057361aa33bf20fb2e98584bc4fec007906e27053f80c6", @@ -112,8 +113,8 @@ "https://bcr.bazel.build/modules/rules_cc/0.1.5/MODULE.bazel": "88dfc9361e8b5ae1008ac38f7cdfd45ad738e4fa676a3ad67d19204f045a1fd8", "https://bcr.bazel.build/modules/rules_cc/0.2.0/MODULE.bazel": "b5c17f90458caae90d2ccd114c81970062946f49f355610ed89bebf954f5783c", "https://bcr.bazel.build/modules/rules_cc/0.2.13/MODULE.bazel": "eecdd666eda6be16a8d9dc15e44b5c75133405e820f620a234acc4b1fdc5aa37", - "https://bcr.bazel.build/modules/rules_cc/0.2.14/MODULE.bazel": "353c99ed148887ee89c54a17d4100ae7e7e436593d104b668476019023b58df8", - "https://bcr.bazel.build/modules/rules_cc/0.2.14/source.json": "55d0a4587c5592fad350f6e698530f4faf0e7dd15e69d43f8d87e220c78bea54", + "https://bcr.bazel.build/modules/rules_cc/0.2.17/MODULE.bazel": "1849602c86cb60da8613d2de887f9566a6d354a6df6d7009f9d04a14402f9a84", + "https://bcr.bazel.build/modules/rules_cc/0.2.17/source.json": "3832f45d145354049137c0090df04629d9c2b5493dc5c2bf46f1834040133a07", "https://bcr.bazel.build/modules/rules_cc/0.2.8/MODULE.bazel": "f1df20f0bf22c28192a794f29b501ee2018fa37a3862a1a2132ae2940a23a642", "https://bcr.bazel.build/modules/rules_foreign_cc/0.9.0/MODULE.bazel": "c9e8c682bf75b0e7c704166d79b599f93b72cfca5ad7477df596947891feeef6", "https://bcr.bazel.build/modules/rules_fuzzing/0.5.2/MODULE.bazel": "40c97d1144356f52905566c55811f13b299453a14ac7769dfba2ac38192337a8", @@ -192,7 +193,7 @@ "moduleExtensions": { "//bun:extensions.bzl%bun": { "general": { - "bzlTransitiveDigest": "mWoMIEcKvXURFuMv68yk2TPrpNykLSLygedENme3WrQ=", + "bzlTransitiveDigest": "lzOUyaXDbkH922ruNkkwEF2cnI4m0XpzrOti0qypwtA=", "usagesDigest": "/0BcCMA6AOzLhQaRK6DquxrCfpPHJUjSUaFz4zmQrsM=", "recordedInputs": [ "REPO_MAPPING:,bazel_tools bazel_tools" @@ -218,6 +219,26 @@ "build_file_content": "\nexports_files([\"bun-linux-aarch64/bun\"])\n\nfilegroup(\n name = \"bun\",\n srcs = [\"bun-linux-aarch64/bun\"],\n visibility = [\"//visibility:public\"],\n)\n" } }, + "bun_linux_x64_musl": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "attributes": { + "urls": [ + "https://github.com/oven-sh/bun/releases/download/bun-v1.3.10/bun-linux-x64-musl.zip" + ], + "sha256": "48a6c32277d343db0148ce066336472ffd380358a4d26bb1329714742492d824", + "build_file_content": "\nexports_files([\"bun-linux-x64-musl/bun\"])\n\nfilegroup(\n name = \"bun\",\n srcs = [\"bun-linux-x64-musl/bun\"],\n visibility = [\"//visibility:public\"],\n)\n" + } + }, + "bun_linux_aarch64_musl": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "attributes": { + "urls": [ + "https://github.com/oven-sh/bun/releases/download/bun-v1.3.10/bun-linux-aarch64-musl.zip" + ], + "sha256": "d2c81365a2e529b78a42330d3a0056e8dbd7896b4a6782c8e392b6532141e34d", + "build_file_content": "\nexports_files([\"bun-linux-aarch64-musl/bun\"])\n\nfilegroup(\n name = \"bun\",\n srcs = [\"bun-linux-aarch64-musl/bun\"],\n visibility = [\"//visibility:public\"],\n)\n" + } + }, "bun_darwin_x64": { "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", "attributes": { @@ -247,6 +268,16 @@ "sha256": "7a77b3e245e2e26965c93089a4a1332e8a326d3364c89fae1d1fd99cdd3cd73d", "build_file_content": "\nexports_files([\"bun-windows-x64/bun.exe\"])\n\nfilegroup(\n name = \"bun\",\n srcs = [\"bun-windows-x64/bun.exe\"],\n visibility = [\"//visibility:public\"],\n)\n" } + }, + "bun_windows_aarch64": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "attributes": { + "urls": [ + "https://github.com/oven-sh/bun/releases/download/bun-v1.3.10/bun-windows-aarch64.zip" + ], + "sha256": "6822f3aa7bd2be40fb94c194a1185aae1c6fade54ca4fc2efdc722e37f3257d2", + "build_file_content": "\nexports_files([\"bun-windows-aarch64/bun.exe\"])\n\nfilegroup(\n name = \"bun\",\n srcs = [\"bun-windows-aarch64/bun.exe\"],\n visibility = [\"//visibility:public\"],\n)\n" + } } } } diff --git a/README.md b/README.md index 12cdaaf..c0bb043 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Bun rules for [Bazel](https://bazel.build) -`rules_bun` provides Bazel rules for running, testing, bundling, and developing -JavaScript and TypeScript code with Bun. +`rules_bun` provides Bazel rules for running, testing, building, compiling, +bundling, and developing JavaScript and TypeScript code with Bun. ## Repository layout @@ -29,6 +29,8 @@ The public entrypoint for rule authors and users is `@rules_bun//bun:defs.bzl`. `rules_bun` exports these primary rules: - `bun_binary` +- `bun_build` +- `bun_compile` - `bun_bundle` - `bun_dev` - `bun_script` @@ -70,9 +72,12 @@ use_repo( bun_ext, "bun_linux_x64", "bun_linux_aarch64", + "bun_linux_x64_musl", + "bun_linux_aarch64_musl", "bun_darwin_x64", "bun_darwin_aarch64", "bun_windows_x64", + "bun_windows_aarch64", ) register_toolchains( @@ -155,6 +160,8 @@ bun_register_toolchains() load( "@rules_bun//bun:defs.bzl", "bun_binary", + "bun_build", + "bun_compile", "bun_bundle", "bun_dev", "bun_script", @@ -194,6 +201,32 @@ When `node_modules` is provided, executables from `node_modules/.bin` are added to `PATH`. This label typically comes from `bun_install`, which still produces a standard `node_modules/` directory. +### `bun_build` and `bun_compile` + +Use `bun_build` for general-purpose `bun build` output directories and +`bun_compile` for standalone executables built with `bun build --compile`. + +```starlark +load("@rules_bun//bun:defs.bzl", "bun_build", "bun_compile") + +bun_build( + name = "site", + entry_points = ["src/index.html"], + data = glob(["src/**"]), + splitting = True, + metafile = True, +) + +bun_compile( + name = "cli", + entry_point = "src/cli.ts", +) +``` + +`bun_build` exposes a directory output so Bun can emit HTML, CSS, assets, and +split chunks. `bun_compile` produces a single executable artifact and supports +explicit cross-compilation via `compile_executable`. + ### `bun_dev` for local development Use `bun_dev` for long-running watch or hot-reload development targets. diff --git a/bun/BUILD.bazel b/bun/BUILD.bazel index 645c682..9b8cd59 100644 --- a/bun/BUILD.bazel +++ b/bun/BUILD.bazel @@ -35,7 +35,9 @@ bzl_library( visibility = ["//visibility:public"], deps = [ ":toolchain_bzl", + "//internal:bun_build_support_bzl", "//internal:bun_binary_bzl", + "//internal:bun_compile_bzl", "//internal:bun_bundle_bzl", "//internal:bun_dev_bzl", "//internal:bun_script_bzl", diff --git a/bun/defs.bzl b/bun/defs.bzl index 4c0ccc7..1fc3db0 100644 --- a/bun/defs.bzl +++ b/bun/defs.bzl @@ -1,4 +1,5 @@ """Public API surface for Bun Bazel rules.""" +load("//internal:bun_compile.bzl", _bun_build = "bun_build", _bun_compile = "bun_compile") 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") @@ -11,6 +12,8 @@ load(":toolchain.bzl", _BunToolchainInfo = "BunToolchainInfo", _bun_toolchain = visibility("public") bun_binary = _bun_binary +bun_build = _bun_build +bun_compile = _bun_compile bun_bundle = _bun_bundle bun_dev = _bun_dev bun_script = _bun_script diff --git a/bun/extensions.bzl b/bun/extensions.bzl index 1b7f9b4..2009234 100644 --- a/bun/extensions.bzl +++ b/bun/extensions.bzl @@ -13,6 +13,16 @@ _BUN_ARCHIVES = { "asset": "bun-linux-aarch64.zip", "binary": "bun-linux-aarch64/bun", }, + "bun_linux_x64_musl": { + "sha256": "48a6c32277d343db0148ce066336472ffd380358a4d26bb1329714742492d824", + "asset": "bun-linux-x64-musl.zip", + "binary": "bun-linux-x64-musl/bun", + }, + "bun_linux_aarch64_musl": { + "sha256": "d2c81365a2e529b78a42330d3a0056e8dbd7896b4a6782c8e392b6532141e34d", + "asset": "bun-linux-aarch64-musl.zip", + "binary": "bun-linux-aarch64-musl/bun", + }, "bun_darwin_x64": { "sha256": "c1d90bf6140f20e572c473065dc6b37a4b036349b5e9e4133779cc642ad94323", "asset": "bun-darwin-x64.zip", @@ -28,6 +38,11 @@ _BUN_ARCHIVES = { "asset": "bun-windows-x64.zip", "binary": "bun-windows-x64/bun.exe", }, + "bun_windows_aarch64": { + "sha256": "6822f3aa7bd2be40fb94c194a1185aae1c6fade54ca4fc2efdc722e37f3257d2", + "asset": "bun-windows-aarch64.zip", + "binary": "bun-windows-aarch64/bun.exe", + }, } _BUN_GITHUB_RELEASE_URL_TEMPLATE = "https://github.com/oven-sh/bun/releases/download/bun-v{}/{}" @@ -62,6 +77,12 @@ _install = tag_class( "bun_lockfile": attr.label(mandatory = True), "install_inputs": attr.label_list(allow_files = True), "isolated_home": attr.bool(default = True), + "production": attr.bool(default = False), + "omit": attr.string_list(), + "linker": attr.string(), + "backend": attr.string(), + "ignore_scripts": attr.bool(default = False), + "install_flags": attr.string_list(), }, ) @@ -75,6 +96,12 @@ def _bun_install_impl(ctx): bun_lockfile = install.bun_lockfile, install_inputs = install.install_inputs, isolated_home = install.isolated_home, + production = install.production, + omit = install.omit, + linker = install.linker, + backend = install.backend, + ignore_scripts = install.ignore_scripts, + install_flags = install.install_flags, visible_repo_name = install.name, ) diff --git a/bun/repositories.bzl b/bun/repositories.bzl index b475d4a..d20a7bc 100644 --- a/bun/repositories.bzl +++ b/bun/repositories.bzl @@ -12,6 +12,16 @@ _BUN_ARCHIVES = { "asset": "bun-linux-aarch64.zip", "binary": "bun-linux-aarch64/bun", }, + "bun_linux_x64_musl": { + "sha256": "48a6c32277d343db0148ce066336472ffd380358a4d26bb1329714742492d824", + "asset": "bun-linux-x64-musl.zip", + "binary": "bun-linux-x64-musl/bun", + }, + "bun_linux_aarch64_musl": { + "sha256": "d2c81365a2e529b78a42330d3a0056e8dbd7896b4a6782c8e392b6532141e34d", + "asset": "bun-linux-aarch64-musl.zip", + "binary": "bun-linux-aarch64-musl/bun", + }, "bun_darwin_x64": { "sha256": "c1d90bf6140f20e572c473065dc6b37a4b036349b5e9e4133779cc642ad94323", "asset": "bun-darwin-x64.zip", @@ -27,6 +37,11 @@ _BUN_ARCHIVES = { "asset": "bun-windows-x64.zip", "binary": "bun-windows-x64/bun.exe", }, + "bun_windows_aarch64": { + "sha256": "6822f3aa7bd2be40fb94c194a1185aae1c6fade54ca4fc2efdc722e37f3257d2", + "asset": "bun-windows-aarch64.zip", + "binary": "bun-windows-aarch64/bun.exe", + }, } _BUN_GITHUB_RELEASE_URL_TEMPLATE = "https://github.com/oven-sh/bun/releases/download/bun-v{}/{}" diff --git a/docs/BUILD.bazel b/docs/BUILD.bazel index 76dccf4..7405060 100644 --- a/docs/BUILD.bazel +++ b/docs/BUILD.bazel @@ -8,6 +8,8 @@ stardoc( input = "//bun:defs.bzl", symbol_names = [ "bun_binary", + "bun_build", + "bun_compile", "bun_bundle", "bun_dev", "bun_script", @@ -19,5 +21,4 @@ stardoc( "ts_library", ], deps = ["//bun:defs_bzl"], - target_compatible_with = ["@platforms//os:linux"], ) diff --git a/docs/bun_install.md b/docs/bun_install.md index 4d2dab0..209d264 100644 --- a/docs/bun_install.md +++ b/docs/bun_install.md @@ -29,6 +29,8 @@ bun_install_ext.install( name = "bun_deps", package_json = "//:package.json", bun_lockfile = "//:bun.lock", + production = True, + omit = ["peer"], ) use_repo(bun_install_ext, "bun_deps") @@ -113,6 +115,45 @@ repository root. - `False`: lets Bun use the host `HOME`, which can improve repeated-install performance when Bun's cache is home-scoped +### `production` + +Optional boolean controlling whether Bun installs only production dependencies. + +Example: + +```starlark +production = True +``` + +### `omit` + +Optional list of dependency groups to omit, forwarded as repeated +`--omit` flags. Common values are `dev`, `optional`, and `peer`. + +### `linker` + +Optional Bun linker strategy, forwarded as `--linker`. + +Common values: + +- `isolated` +- `hoisted` + +### `backend` + +Optional Bun install backend, forwarded as `--backend`. + +Examples include `hardlink`, `symlink`, and `copyfile`. + +### `ignore_scripts` + +Optional boolean controlling whether Bun skips lifecycle scripts in the project +manifest. + +### `install_flags` + +Optional list of additional raw flags forwarded to `bun install`. + ## Notes - `bun_install` runs Bun, not npm. diff --git a/docs/index.md b/docs/index.md index d5a0a09..db90505 100644 --- a/docs/index.md +++ b/docs/index.md @@ -36,9 +36,12 @@ use_repo( bun_ext, "bun_linux_x64", "bun_linux_aarch64", + "bun_linux_x64_musl", + "bun_linux_aarch64_musl", "bun_darwin_x64", "bun_darwin_aarch64", "bun_windows_x64", + "bun_windows_aarch64", ) register_toolchains( @@ -79,6 +82,12 @@ bun_script( `bun_script` runs from the package directory by default and adds `node_modules/.bin` to `PATH`. +## Build and compile + +Use `bun_build` when Bun may emit a directory of outputs such as HTML, CSS, +chunks, and static assets. Use `bun_compile` for standalone executables created +with `bun build --compile`. + ## Regeneration The rule reference is generated from the public Starlark symbols in diff --git a/docs/rules.md b/docs/rules.md index 8aaf823..61c73b7 100644 --- a/docs/rules.md +++ b/docs/rules.md @@ -1,135 +1,484 @@ -# rules_bun rule reference + -This file documents the public rules exported from `@rules_bun//bun:defs.bzl`. +Public API surface for Bun Bazel rules. -## js_binary - -Runs a JS/TS entry point with Bun behind a `rules_js`-style name. - -Attributes: - -- `entry_point` (label, required): path to the main JS/TS file to execute. -- `node_modules` (label, optional): package files from a `node_modules` tree, typically produced by `bun_install` or `npm_translate_lock`, made available in runfiles. -- `data` (label_list, optional): additional runtime files. -- `deps` (label_list, optional): library dependencies required by the program. -- `args` (string_list, optional): default arguments appended before command-line arguments passed to the binary. -- `working_dir` (string, default: `"workspace"`, values: `"workspace" | "entry_point"`): runtime working directory. - -## js_test - -Runs Bun tests behind a `rules_js`-style name. - -Attributes: - -- `srcs` (label_list, required): test source files passed to `bun test`. -- `node_modules` (label, optional): package files from a `node_modules` tree, typically produced by `bun_install` or `npm_translate_lock`, made available in runfiles. -- `deps` (label_list, optional): library dependencies required by tests. -- `data` (label_list, optional): additional runtime files needed by tests. -- `args` (string_list, optional): default arguments appended after the test source list. - -## js_run_devserver - -Runs an executable target from a staged JS workspace. - -Attributes: - -- `tool` (label, required): executable target to launch as the dev server. -- `args` (string_list, optional): default arguments appended before command-line arguments passed to the dev server. -- `package_json` (label, optional): package manifest used to resolve the package working directory. -- `package_dir_hint` (string, default: `"."`): package-relative directory hint when `package_json` is omitted. -- `node_modules` (label, optional): package files from a `node_modules` tree, typically produced by `bun_install` or `npm_translate_lock`, made available in runfiles. -- `deps` (label_list, optional): library dependencies required by the dev server. -- `data` (label_list, optional): additional runtime files. -- `working_dir` (string, default: `"workspace"`, values: `"workspace" | "package"`): runtime working directory. + ## bun_binary -Runs a JS/TS entry point with Bun as an executable target (`bazel run`). +
+load("@rules_bun//bun:defs.bzl", "bun_binary")
-Attributes:
+bun_binary(name, deps, data, conditions, entry_point, env_files, install_mode, no_env_file,
+ node_modules, preload, run_flags, smol, working_dir)
+
-- `entry_point` (label, required): path to the main JS/TS file to execute.
-- `node_modules` (label, optional): package files from a `node_modules` tree, typically produced by `bun_install`, made available in runfiles.
-- `data` (label_list, optional): additional runtime files.
-- `deps` (label_list, optional): library dependencies required by the program.
-- `args` (string_list, optional): default arguments appended before command-line arguments passed to the binary.
-- `working_dir` (string, default: `"workspace"`, values: `"workspace" | "entry_point"`): runtime working directory.
+Runs a JS/TS entry point with Bun as an executable target.
-## bun_dev
+Use this rule for non-test scripts and CLIs that should run via `bazel run`.
-Runs a JS/TS entry point in Bun development watch mode (`bazel run`).
+**ATTRIBUTES**
-Attributes:
-- `entry_point` (label, required): path to the main JS/TS file.
-- `watch_mode` (string, default: `"watch"`, values: `"watch" | "hot"`): Bun live-reload mode.
-- `restart_on` (label_list, optional): files that trigger full process restart when changed.
-- `node_modules` (label, optional): package files from a `node_modules` tree, typically produced by `bun_install`, made available in runfiles.
-- `data` (label_list, optional): additional runtime files for dev process.
-- `working_dir` (string, default: `"workspace"`, values: `"workspace" | "entry_point"`): runtime working directory.
+| Name | Description | Type | Mandatory | Default |
+| :------------- | :------------- | :------------- | :------------- | :------------- |
+| name | A unique name for this target. | Name | required | |
+| deps | Library dependencies required by the program. | List of labels | optional | `[]` |
+| data | Additional runtime files required by the program. | List of labels | optional | `[]` |
+| conditions | Custom package resolve conditions passed to Bun. | List of strings | optional | `[]` |
+| entry_point | Path to the main JS/TS file to execute. | Label | required | |
+| env_files | Additional environment files loaded with `--env-file`. | List of labels | optional | `[]` |
+| install_mode | Whether Bun may auto-install missing packages at runtime. | String | optional | `"disable"` |
+| no_env_file | If true, disables Bun's automatic `.env` loading. | Boolean | optional | `False` |
+| node_modules | Optional label providing package files from a `node_modules` tree, typically produced by `bun_install`, in runfiles. | Label | optional | `None` |
+| preload | Modules to preload with `--preload` before running the entry point. | List of labels | optional | `[]` |
+| run_flags | Additional raw flags forwarded to `bun run` before the entry point. | List of strings | optional | `[]` |
+| smol | If true, enables Bun's lower-memory runtime mode. | Boolean | optional | `False` |
+| working_dir | Working directory at runtime: `workspace` root or nearest `entry_point` ancestor containing `.env`/`package.json`. | String | optional | `"workspace"` |
-## bun_script
-Runs a named `package.json` script with Bun as an executable target (`bazel run`).
+
-Recommended for package-script based tools such as Vite (`dev`, `build`, `preview`).
-When `node_modules` is provided, executables from `node_modules/.bin` are added
-to `PATH`, so scripts like `vite` work without wrapper scripts.
+## bun_build
-Attributes:
+
+load("@rules_bun//bun:defs.bzl", "bun_build")
-- `script` (string, required): package script name passed to `bun run
+