Compare commits
51 Commits
copilot/ad
...
docs/match
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
10758aa20a | ||
|
|
fb7afbb138 | ||
|
|
3a07d02c0d | ||
|
|
a3591b85a5 | ||
|
|
dae19ed2dc | ||
|
|
e84bd920be | ||
|
|
7569ca914c | ||
|
|
cac266ee25 | ||
|
|
bf87497c27 | ||
|
|
0872bf7b20 | ||
|
|
075a1159cf | ||
|
|
d5b3f5c5ac | ||
|
|
63839fce52 | ||
|
|
ab6ee39f62 | ||
|
|
22220b6408 | ||
|
|
90be857640 | ||
|
|
6b1a2ce1c0 | ||
|
|
092aa0cc14 | ||
|
|
5dda02dba3 | ||
|
|
9116913740 | ||
|
|
07210d89d2 | ||
|
|
799fe61c56 | ||
|
|
ce9fff76a3 | ||
|
|
45e8f75ca5 | ||
|
|
c00d949936 | ||
|
|
c25535b59b | ||
|
|
96d0c2e79d | ||
|
|
56fbea32d8 | ||
|
|
c823d3ec19 | ||
|
|
f5d42b24db | ||
|
|
3bf65e9fc6 | ||
|
|
ed3b159dc2 | ||
|
|
5302f573fb | ||
|
|
db16748cd1 | ||
|
|
bdc5e6d976 | ||
|
|
972a7b238d | ||
|
|
d1b209eb0e | ||
|
|
604dc41a95 | ||
|
|
7b549e9b4f | ||
|
|
b33a395c44 | ||
|
|
7d4b9abdd9 | ||
|
|
861a677582 | ||
|
|
42469425e1 | ||
|
|
5044478363 | ||
|
|
324ca9395b | ||
|
|
bd6bebd562 | ||
|
|
e69e2754ca | ||
|
|
fbfdef222d | ||
|
|
5220c76290 | ||
|
|
ebce24804c | ||
|
|
b66339a33b |
5
.github/workflows/BUILD.bazel
vendored
5
.github/workflows/BUILD.bazel
vendored
@@ -1,3 +1,6 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
exports_files(["ci.yml"])
|
||||
exports_files([
|
||||
"ci.yml",
|
||||
"pages.yml",
|
||||
])
|
||||
|
||||
10
.github/workflows/ci.yml
vendored
10
.github/workflows/ci.yml
vendored
@@ -5,6 +5,10 @@ on:
|
||||
branches: ["main"]
|
||||
pull_request:
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
test:
|
||||
permissions:
|
||||
@@ -25,6 +29,12 @@ 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 }}"
|
||||
|
||||
6
.github/workflows/copilot-setup-steps.yml
vendored
6
.github/workflows/copilot-setup-steps.yml
vendored
@@ -35,5 +35,11 @@ jobs:
|
||||
extra_nix_config: |
|
||||
experimental-features = nix-command flakes
|
||||
|
||||
- name: Restore and save Nix store cache
|
||||
uses: nix-community/cache-nix-action@v7
|
||||
with:
|
||||
primary-key: nix-${{ runner.os }}-${{ hashFiles('**/*.nix', '**/flake.lock') }}
|
||||
restore-prefixes-first-match: nix-${{ runner.os }}-
|
||||
|
||||
- name: Install flake dependencies
|
||||
run: nix develop --accept-flake-config -c true
|
||||
|
||||
61
.github/workflows/pages.yml
vendored
Normal file
61
.github/workflows/pages.yml
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
name: Docs Pages
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ["main"]
|
||||
paths:
|
||||
- "docs/**"
|
||||
- "bun/**/*.bzl"
|
||||
- "internal/**/*.bzl"
|
||||
- ".github/workflows/pages.yml"
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
pages: write
|
||||
id-token: write
|
||||
|
||||
concurrency:
|
||||
group: pages
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
USE_BAZEL_VERSION: 9.0.0
|
||||
environment:
|
||||
name: github-pages
|
||||
url: ${{ steps.deployment.outputs.page_url }}
|
||||
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: docs-pages
|
||||
|
||||
- name: Generate rule docs
|
||||
run: |
|
||||
bazel build //docs:rules_md
|
||||
cp bazel-bin/docs/rules.md docs/rules.md
|
||||
|
||||
- name: Setup Pages
|
||||
uses: actions/configure-pages@v5
|
||||
|
||||
- name: Build with Jekyll
|
||||
uses: actions/jekyll-build-pages@v1
|
||||
with:
|
||||
source: docs
|
||||
destination: _site
|
||||
|
||||
- name: Upload Pages artifact
|
||||
uses: actions/upload-pages-artifact@v3
|
||||
with:
|
||||
path: _site
|
||||
|
||||
- name: Deploy to GitHub Pages
|
||||
id: deployment
|
||||
uses: actions/deploy-pages@v4
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -11,6 +11,7 @@
|
||||
build/
|
||||
dist/
|
||||
node_modules/
|
||||
*/node_modules/
|
||||
|
||||
# Directories for the Bazel IntelliJ plugin containing the generated
|
||||
# IntelliJ project files and plugin configuration. Seperate directories are
|
||||
@@ -20,3 +21,6 @@ node_modules/
|
||||
/.clwb/
|
||||
|
||||
.env
|
||||
!tests/.env
|
||||
!examples/.env
|
||||
.direnv
|
||||
1
.pre-commit-config.yaml
Symbolic link
1
.pre-commit-config.yaml
Symbolic link
@@ -0,0 +1 @@
|
||||
/nix/store/vq88dl8yys4hbw4gq6kwypah5ykqr8xs-pre-commit-config.json
|
||||
22
MODULE.bazel
22
MODULE.bazel
@@ -1,21 +1,35 @@
|
||||
module(
|
||||
name = "rules_bun",
|
||||
version = "0.1.0",
|
||||
version = "0.2.0",
|
||||
)
|
||||
|
||||
# Core ruleset dependencies.
|
||||
bazel_dep(name = "platforms", version = "1.0.0")
|
||||
bazel_dep(name = "rules_shell", version = "0.6.1")
|
||||
bazel_dep(name = "bazel_skylib", version = "1.8.2")
|
||||
bazel_dep(name = "stardoc", version = "0.7.2")
|
||||
|
||||
# Repository-local setup for this ruleset's own tests and examples.
|
||||
bun_ext = use_extension("//bun:extensions.bzl", "bun")
|
||||
use_repo(
|
||||
bun_ext,
|
||||
"bun_linux_x64",
|
||||
"bun_linux_aarch64",
|
||||
"bun_darwin_x64",
|
||||
"bun_darwin_aarch64",
|
||||
"bun_darwin_x64",
|
||||
"bun_linux_aarch64",
|
||||
"bun_linux_x64",
|
||||
"bun_windows_x64",
|
||||
)
|
||||
|
||||
# Test fixture dependency installation used by //tests/script_test.
|
||||
bun_install_ext = use_extension("//bun:extensions.bzl", "bun_install")
|
||||
bun_install_ext.install(
|
||||
name = "script_test_vite_node_modules",
|
||||
package_json = "//tests/script_test:vite_app/package.json",
|
||||
bun_lockfile = "//tests/script_test:vite_app/bun.lock",
|
||||
)
|
||||
use_repo(bun_install_ext, "script_test_vite_node_modules")
|
||||
|
||||
# Register the published Bun toolchains for this repository.
|
||||
register_toolchains(
|
||||
"//bun:darwin_aarch64_toolchain",
|
||||
"//bun:darwin_x64_toolchain",
|
||||
|
||||
22
MODULE.bazel.lock
generated
22
MODULE.bazel.lock
generated
@@ -189,8 +189,8 @@
|
||||
"moduleExtensions": {
|
||||
"//bun:extensions.bzl%bun": {
|
||||
"general": {
|
||||
"bzlTransitiveDigest": "Q0uQOwFAgAU+etePCZ4TUDO+adLX7Z0EmRLaEsKgncw=",
|
||||
"usagesDigest": "qk1PDh3WICa0VONYKXJLsmWCesNJxz3Jkb/aH/voIeI=",
|
||||
"bzlTransitiveDigest": "83P5DLnVhSu3AwYrHPGqYVY/L6twnM4Jnlhc8uAOOls=",
|
||||
"usagesDigest": "SXT282ETYzRFxBNaQrX/Ym1rZzueKzjlll/D0arFoYs=",
|
||||
"recordedInputs": [
|
||||
"REPO_MAPPING:,bazel_tools bazel_tools"
|
||||
],
|
||||
@@ -248,6 +248,24 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"//bun:extensions.bzl%bun_install": {
|
||||
"general": {
|
||||
"bzlTransitiveDigest": "83P5DLnVhSu3AwYrHPGqYVY/L6twnM4Jnlhc8uAOOls=",
|
||||
"usagesDigest": "BSZJHRsUZpMHTxqlUZZaq4MH8kfqrzFfF+50EqSPx/Q=",
|
||||
"recordedInputs": [
|
||||
"REPO_MAPPING:,bazel_tools bazel_tools"
|
||||
],
|
||||
"generatedRepoSpecs": {
|
||||
"script_test_vite_node_modules": {
|
||||
"repoRuleId": "@@//internal:bun_install.bzl%bun_install_repository",
|
||||
"attributes": {
|
||||
"package_json": "@@//tests/script_test:vite_app/package.json",
|
||||
"bun_lockfile": "@@//tests/script_test:vite_app/bun.lock"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@@rules_kotlin+//src/main/starlark/core/repositories:bzlmod_setup.bzl%rules_kotlin_extensions": {
|
||||
"general": {
|
||||
"bzlTransitiveDigest": "ABI1D/sbS1ovwaW/kHDoj8nnXjQ0oKU9fzmzEG4iT8o=",
|
||||
|
||||
214
README.md
214
README.md
@@ -1,53 +1,197 @@
|
||||
# rules_bun
|
||||
# Bun rules for [Bazel](https://bazel.build)
|
||||
|
||||
Bazel rules for bun.
|
||||
`rules_bun` provides Bazel rules for running, testing, bundling, and developing
|
||||
JavaScript and TypeScript code with Bun.
|
||||
|
||||
## Current status
|
||||
## Repository layout
|
||||
|
||||
Phase 1 bootstrap is in place:
|
||||
This repository follows the standard Bazel ruleset layout:
|
||||
|
||||
- Bun toolchain rule and provider (`/bun/toolchain.bzl`)
|
||||
- Platform-specific Bun repository downloads (`/bun/repositories.bzl`)
|
||||
- Toolchain declarations and registration targets (`/bun/BUILD.bazel`)
|
||||
- Smoke test for `bun --version` (`//tests/toolchain_test:bun_version_test`)
|
||||
```text
|
||||
/
|
||||
MODULE.bazel
|
||||
README.md
|
||||
bun/
|
||||
BUILD.bazel
|
||||
defs.bzl
|
||||
extensions.bzl
|
||||
repositories.bzl
|
||||
toolchain.bzl
|
||||
docs/
|
||||
examples/
|
||||
tests/
|
||||
```
|
||||
|
||||
Phase 2 bootstrap is in place:
|
||||
The public entrypoint for rule authors and users is `@rules_bun//bun:defs.bzl`.
|
||||
|
||||
- Repository-rule based `bun_install` (`/internal/bun_install.bzl`)
|
||||
- Public export via `bun/defs.bzl`
|
||||
- Focused install behavior tests (`//tests/install_test:all`)
|
||||
## Public API
|
||||
|
||||
Phase 3 bootstrap is in place:
|
||||
`rules_bun` exports these primary rules:
|
||||
|
||||
- Executable `bun_binary` rule (`/internal/bun_binary.bzl`)
|
||||
- Public export via `bun/defs.bzl`
|
||||
- Focused JS/TS runnable tests (`//tests/binary_test:all`)
|
||||
- `bun_binary`
|
||||
- `bun_bundle`
|
||||
- `bun_dev`
|
||||
- `bun_script`
|
||||
- `bun_test`
|
||||
- `js_library`
|
||||
- `ts_library`
|
||||
|
||||
Phase 4 bootstrap is in place:
|
||||
Reference documentation:
|
||||
|
||||
- Test rule `bun_test` (`/internal/bun_test.bzl`)
|
||||
- Public export via `bun/defs.bzl`
|
||||
- Focused passing/failing test targets (`//tests/bun_test_test:all`)
|
||||
- Published docs site: https://eriyc.github.io/rules_bun/
|
||||
- Generated rule reference: [docs/rules.md](docs/rules.md)
|
||||
- Docs index: [docs/index.md](docs/index.md)
|
||||
|
||||
Phase 5 bootstrap is in place:
|
||||
To refresh generated rule docs:
|
||||
|
||||
- Bundle rule `bun_bundle` (`/internal/bun_bundle.bzl`)
|
||||
- Public export via `bun/defs.bzl`
|
||||
- Focused output/minify tests (`//tests/bundle_test:all`)
|
||||
```bash
|
||||
bazel build //docs:rules_md && cp bazel-bin/docs/rules.md docs/rules.md
|
||||
```
|
||||
|
||||
Phase 6 bootstrap is in place:
|
||||
## Bzlmod usage
|
||||
|
||||
- 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`)
|
||||
Release announcements should provide a copy-pasteable module snippet in the
|
||||
standard ruleset form:
|
||||
|
||||
Phase 7 bootstrap is in place:
|
||||
```starlark
|
||||
bazel_dep(name = "rules_bun", version = "0.2.0")
|
||||
```
|
||||
|
||||
- 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`)
|
||||
Then add the Bun repositories and register the toolchains in `MODULE.bazel`:
|
||||
|
||||
Phase 8 bootstrap is in place:
|
||||
```starlark
|
||||
bun_ext = use_extension("@rules_bun//bun:extensions.bzl", "bun")
|
||||
|
||||
- CI matrix workflow for linux-x64, darwin-arm64, and windows (`/.github/workflows/ci.yml`)
|
||||
- Bazel 9 pin in CI via `USE_BAZEL_VERSION=9.0.0`
|
||||
- Focused CI matrix shape test (`//tests/ci_test:all`)
|
||||
use_repo(
|
||||
bun_ext,
|
||||
"bun_linux_x64",
|
||||
"bun_linux_aarch64",
|
||||
"bun_darwin_x64",
|
||||
"bun_darwin_aarch64",
|
||||
"bun_windows_x64",
|
||||
)
|
||||
|
||||
register_toolchains(
|
||||
"@rules_bun//bun:darwin_aarch64_toolchain",
|
||||
"@rules_bun//bun:darwin_x64_toolchain",
|
||||
"@rules_bun//bun:linux_aarch64_toolchain",
|
||||
"@rules_bun//bun:linux_x64_toolchain",
|
||||
"@rules_bun//bun:windows_x64_toolchain",
|
||||
)
|
||||
```
|
||||
|
||||
If you want Bazel-managed dependency installation, also add the module
|
||||
extension for `bun_install`:
|
||||
|
||||
```starlark
|
||||
bun_install_ext = use_extension("@rules_bun//bun:extensions.bzl", "bun_install")
|
||||
|
||||
bun_install_ext.install(
|
||||
name = "npm",
|
||||
package_json = "//:package.json",
|
||||
bun_lockfile = "//:bun.lock",
|
||||
)
|
||||
|
||||
use_repo(bun_install_ext, "npm")
|
||||
```
|
||||
|
||||
## Legacy WORKSPACE usage
|
||||
|
||||
For non-Bzlmod consumers, the repository exposes a legacy setup macro in
|
||||
`@rules_bun//bun:repositories.bzl`:
|
||||
|
||||
```starlark
|
||||
load("@rules_bun//bun:repositories.bzl", "bun_register_toolchains")
|
||||
|
||||
bun_register_toolchains()
|
||||
```
|
||||
|
||||
## Loading rules in BUILD files
|
||||
|
||||
```starlark
|
||||
load(
|
||||
"@rules_bun//bun:defs.bzl",
|
||||
"bun_binary",
|
||||
"bun_bundle",
|
||||
"bun_dev",
|
||||
"bun_script",
|
||||
"bun_test",
|
||||
"js_library",
|
||||
"ts_library",
|
||||
)
|
||||
```
|
||||
|
||||
## Common workflows
|
||||
|
||||
### `bun_script` for package scripts
|
||||
|
||||
Use `bun_script` to expose a `package.json` script as a Bazel executable.
|
||||
This is the recommended way to run Vite-style `dev`, `build`, and `preview`
|
||||
scripts.
|
||||
|
||||
```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",
|
||||
]),
|
||||
)
|
||||
```
|
||||
|
||||
When `node_modules` is provided, executables from `node_modules/.bin` are added
|
||||
to `PATH`.
|
||||
|
||||
### `bun_dev` for local development
|
||||
|
||||
Use `bun_dev` for long-running watch or hot-reload development targets.
|
||||
|
||||
```starlark
|
||||
load("@rules_bun//bun:defs.bzl", "bun_dev")
|
||||
|
||||
bun_dev(
|
||||
name = "web_dev",
|
||||
entry_point = "src/main.ts",
|
||||
# Optional: run from the entry point directory so Bun auto-loads colocated .env files.
|
||||
# working_dir = "entry_point",
|
||||
)
|
||||
```
|
||||
|
||||
Supported development options include:
|
||||
|
||||
- `watch_mode = "watch"`
|
||||
- `watch_mode = "hot"`
|
||||
- `restart_on = [...]`
|
||||
- `working_dir = "workspace" | "entry_point"`
|
||||
|
||||
### Working directory behavior
|
||||
|
||||
`bun_binary` and `bun_dev` support `working_dir`:
|
||||
|
||||
- `"workspace"`: run from the Bazel runfiles workspace root.
|
||||
- `"entry_point"`: run from the nearest ancestor of the entry point that
|
||||
contains `.env` or `package.json`.
|
||||
|
||||
## Tests and examples
|
||||
|
||||
The repository keeps conformance and integration coverage in [tests/](tests/) and
|
||||
usage samples in [examples/](examples/).
|
||||
|
||||
Representative example docs:
|
||||
|
||||
- [examples/basic/README.md](examples/basic/README.md)
|
||||
- [examples/workspace/README.md](examples/workspace/README.md)
|
||||
|
||||
To validate the ruleset locally:
|
||||
|
||||
```bash
|
||||
bazel test //tests/...
|
||||
```
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
workspace(name = "rules_bun")
|
||||
|
||||
load("//internal:bun_install.bzl", "bun_install")
|
||||
load("//bun:repositories.bzl", "bun_register_toolchains")
|
||||
|
||||
bun_register_toolchains()
|
||||
|
||||
bun_install(
|
||||
name = "script_test_vite_node_modules",
|
||||
package_json = "//tests/script_test:vite_app/package.json",
|
||||
bun_lockfile = "//tests/script_test:vite_app/bun.lock",
|
||||
)
|
||||
|
||||
@@ -1,11 +1,49 @@
|
||||
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
|
||||
load(":toolchain.bzl", "bun_toolchain")
|
||||
load(":version.bzl", "BUN_VERSION")
|
||||
|
||||
exports_files([
|
||||
"defs.bzl",
|
||||
"extensions.bzl",
|
||||
"repositories.bzl",
|
||||
"toolchain.bzl",
|
||||
"version.bzl",
|
||||
])
|
||||
|
||||
bzl_library(
|
||||
name = "toolchain_bzl",
|
||||
srcs = ["toolchain.bzl"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
bzl_library(
|
||||
name = "extensions_bzl",
|
||||
srcs = ["extensions.bzl"],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = ["//internal:bun_install_bzl"],
|
||||
)
|
||||
|
||||
bzl_library(
|
||||
name = "repositories_bzl",
|
||||
srcs = ["repositories.bzl"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
bzl_library(
|
||||
name = "defs_bzl",
|
||||
srcs = ["defs.bzl"],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
":toolchain_bzl",
|
||||
"//internal:bun_binary_bzl",
|
||||
"//internal:bun_bundle_bzl",
|
||||
"//internal:bun_dev_bzl",
|
||||
"//internal:bun_script_bzl",
|
||||
"//internal:bun_test_bzl",
|
||||
"//internal:js_library_bzl",
|
||||
],
|
||||
)
|
||||
|
||||
toolchain_type(name = "toolchain_type")
|
||||
|
||||
bun_toolchain(
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
"""Public API surface for Bun Bazel rules."""
|
||||
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")
|
||||
@@ -8,8 +11,11 @@ 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
|
||||
BunToolchainInfo = _BunToolchainInfo
|
||||
bun_toolchain = _bun_toolchain
|
||||
|
||||
19
docs/BUILD.bazel
Normal file
19
docs/BUILD.bazel
Normal file
@@ -0,0 +1,19 @@
|
||||
load("@stardoc//stardoc:stardoc.bzl", "stardoc")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
stardoc(
|
||||
name = "rules_md",
|
||||
out = "rules.md",
|
||||
input = "//bun:defs.bzl",
|
||||
symbol_names = [
|
||||
"bun_binary",
|
||||
"bun_bundle",
|
||||
"bun_dev",
|
||||
"bun_script",
|
||||
"bun_test",
|
||||
"js_library",
|
||||
"ts_library",
|
||||
],
|
||||
deps = ["//bun:defs_bzl"],
|
||||
)
|
||||
82
docs/index.md
Normal file
82
docs/index.md
Normal file
@@ -0,0 +1,82 @@
|
||||
# rules_bun docs
|
||||
|
||||
Documentation for `rules_bun`, a Bazel ruleset for Bun.
|
||||
|
||||
## Ruleset layout
|
||||
|
||||
The repository exposes its public Bazel API from the [bun/](../bun/) package:
|
||||
|
||||
- `@rules_bun//bun:defs.bzl` for build rules
|
||||
- `@rules_bun//bun:extensions.bzl` for Bzlmod extensions
|
||||
- `@rules_bun//bun:repositories.bzl` for legacy WORKSPACE setup
|
||||
|
||||
Supporting material lives in:
|
||||
|
||||
- [examples/](../examples/) for usage samples
|
||||
- [tests/](../tests/) for repository conformance and integration tests
|
||||
- [docs/rules.md](rules.md) for generated rule reference
|
||||
|
||||
## Rule reference
|
||||
|
||||
- [rules.md](rules.md)
|
||||
|
||||
## Typical Bzlmod setup
|
||||
|
||||
```starlark
|
||||
bazel_dep(name = "rules_bun", version = "0.2.0")
|
||||
|
||||
bun_ext = use_extension("@rules_bun//bun:extensions.bzl", "bun")
|
||||
|
||||
use_repo(
|
||||
bun_ext,
|
||||
"bun_linux_x64",
|
||||
"bun_linux_aarch64",
|
||||
"bun_darwin_x64",
|
||||
"bun_darwin_aarch64",
|
||||
"bun_windows_x64",
|
||||
)
|
||||
|
||||
register_toolchains(
|
||||
"@rules_bun//bun:darwin_aarch64_toolchain",
|
||||
"@rules_bun//bun:darwin_x64_toolchain",
|
||||
"@rules_bun//bun:linux_aarch64_toolchain",
|
||||
"@rules_bun//bun:linux_x64_toolchain",
|
||||
"@rules_bun//bun:windows_x64_toolchain",
|
||||
)
|
||||
```
|
||||
|
||||
## Vite package scripts
|
||||
|
||||
Use `bun_script` for package-script driven workflows such as `dev`, `build`,
|
||||
and `preview`.
|
||||
|
||||
```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/**",
|
||||
"public/**",
|
||||
"index.html",
|
||||
"vite.config.*",
|
||||
"tsconfig*.json",
|
||||
]),
|
||||
)
|
||||
```
|
||||
|
||||
`bun_script` runs from the package directory by default and adds
|
||||
`node_modules/.bin` to `PATH`.
|
||||
|
||||
## Regeneration
|
||||
|
||||
The rule reference is generated from the public Starlark symbols in
|
||||
`@rules_bun//bun:defs.bzl`:
|
||||
|
||||
```bash
|
||||
bazel build //docs:rules_md
|
||||
cp bazel-bin/docs/rules.md docs/rules.md
|
||||
```
|
||||
88
docs/rules.md
Normal file
88
docs/rules.md
Normal file
@@ -0,0 +1,88 @@
|
||||
# rules_bun rule reference
|
||||
|
||||
This file documents the public rules exported from `@rules_bun//bun:defs.bzl`.
|
||||
|
||||
## bun_binary
|
||||
|
||||
Runs a JS/TS entry point with Bun as an executable target (`bazel run`).
|
||||
|
||||
Attributes:
|
||||
|
||||
- `entry_point` (label, required): path to the main JS/TS file to execute.
|
||||
- `node_modules` (label, optional): Bun/npm package files in runfiles.
|
||||
- `data` (label_list, optional): additional runtime files.
|
||||
- `working_dir` (string, default: `"workspace"`, values: `"workspace" | "entry_point"`): runtime working directory.
|
||||
|
||||
## bun_dev
|
||||
|
||||
Runs a JS/TS entry point in Bun development watch mode (`bazel run`).
|
||||
|
||||
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): Bun/npm package files in runfiles.
|
||||
- `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`).
|
||||
|
||||
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.
|
||||
|
||||
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. The default is a good fit for Vite and similar package-script based tools.
|
||||
|
||||
## bun_bundle
|
||||
|
||||
Bundles one or more JS/TS entry points with Bun build.
|
||||
|
||||
Attributes:
|
||||
|
||||
- `entry_points` (label_list, required): entry files to bundle.
|
||||
- `node_modules` (label, optional): Bun/npm package files for resolution.
|
||||
- `deps` (label_list, optional): source/library dependencies for transitive inputs.
|
||||
- `data` (label_list, optional): additional non-source files needed during bundling.
|
||||
- `target` (string, default: `"browser"`, values: `"browser" | "node" | "bun"`): Bun build target.
|
||||
- `format` (string, default: `"esm"`, values: `"esm" | "cjs" | "iife"`): module format.
|
||||
- `minify` (bool, default: `False`): minifies bundle output.
|
||||
- `sourcemap` (bool, default: `False`): emits source maps.
|
||||
- `external` (string_list, optional): package names treated as external (not bundled).
|
||||
|
||||
## bun_test
|
||||
|
||||
Runs Bun tests as a Bazel test target (`bazel test`).
|
||||
|
||||
Attributes:
|
||||
|
||||
- `srcs` (label_list, required): test source files passed to `bun test`.
|
||||
- `node_modules` (label, optional): Bun/npm package files in runfiles.
|
||||
- `deps` (label_list, optional): library dependencies required by tests.
|
||||
- `data` (label_list, optional): additional runtime files needed by tests.
|
||||
|
||||
## js_library
|
||||
|
||||
Aggregates JavaScript sources and transitive Bun source dependencies.
|
||||
|
||||
Attributes:
|
||||
|
||||
- `srcs` (label_list, optional): `.js`, `.jsx`, `.mjs`, `.cjs` files.
|
||||
- `deps` (label_list, optional): dependent source libraries.
|
||||
|
||||
## ts_library
|
||||
|
||||
Aggregates TypeScript sources and transitive Bun source dependencies.
|
||||
|
||||
Attributes:
|
||||
|
||||
- `srcs` (label_list, optional): `.ts`, `.tsx` files.
|
||||
- `deps` (label_list, optional): dependent source libraries.
|
||||
@@ -1,5 +1,13 @@
|
||||
load("//bun:defs.bzl", "bun_dev")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
exports_files([
|
||||
"README.md",
|
||||
"main.ts",
|
||||
])
|
||||
|
||||
bun_dev(
|
||||
name = "web_dev",
|
||||
entry_point = "main.ts",
|
||||
)
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
# basic example
|
||||
|
||||
Placeholder for end-to-end bun rules example.
|
||||
Minimal `bun_dev` example.
|
||||
|
||||
Run:
|
||||
|
||||
```bash
|
||||
bazel run //examples/basic:web_dev
|
||||
```
|
||||
|
||||
This starts Bun in watch mode for `main.ts`.
|
||||
|
||||
1
examples/basic/main.ts
Normal file
1
examples/basic/main.ts
Normal file
@@ -0,0 +1 @@
|
||||
console.log("rules_bun bun_dev example");
|
||||
12
flake.lock
generated
12
flake.lock
generated
@@ -9,16 +9,16 @@
|
||||
"treefmt-nix": "treefmt-nix"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1772610504,
|
||||
"narHash": "sha256-uoMnjsab5IpZRZ/1mn5oVy4fRnAYn6b58E3FNa+jyQY=",
|
||||
"ref": "v1.0.4",
|
||||
"rev": "86a0792b6e54104e8cb33983cabc175aea8da464",
|
||||
"revCount": 33,
|
||||
"lastModified": 1772815059,
|
||||
"narHash": "sha256-9Mn8t/a7b43omtmKRsF0HmFpCkNpTsvYEq0y85KLL5s=",
|
||||
"ref": "v2.0.1",
|
||||
"rev": "80cc529de7060e079d89a69d8daaf0347b53d8f9",
|
||||
"revCount": 43,
|
||||
"type": "git",
|
||||
"url": "https://git.dgren.dev/eric/nix-flake-lib"
|
||||
},
|
||||
"original": {
|
||||
"ref": "v1.0.4",
|
||||
"ref": "v2.0.1",
|
||||
"type": "git",
|
||||
"url": "https://git.dgren.dev/eric/nix-flake-lib"
|
||||
}
|
||||
|
||||
46
flake.nix
46
flake.nix
@@ -3,12 +3,13 @@
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
|
||||
devshell-lib.url = "git+https://git.dgren.dev/eric/nix-flake-lib?ref=v1.0.4";
|
||||
devshell-lib.url = "git+https://git.dgren.dev/eric/nix-flake-lib?ref=v2.0.1";
|
||||
devshell-lib.inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
outputs =
|
||||
{
|
||||
self,
|
||||
nixpkgs,
|
||||
devshell-lib,
|
||||
...
|
||||
@@ -41,10 +42,11 @@
|
||||
bun
|
||||
bazel9
|
||||
bazel-buildtools
|
||||
self.packages.${system}.release
|
||||
];
|
||||
|
||||
features = {
|
||||
oxfmt = true;
|
||||
oxfmt = false;
|
||||
};
|
||||
|
||||
formatters = {
|
||||
@@ -86,7 +88,7 @@
|
||||
name = "Bazel";
|
||||
bin = "${bazel9}/bin/bazel";
|
||||
versionCmd = "--version";
|
||||
color = "BLUE";
|
||||
color = "GREEN";
|
||||
}
|
||||
];
|
||||
|
||||
@@ -128,7 +130,43 @@
|
||||
release = devshell-lib.lib.mkRelease {
|
||||
inherit system;
|
||||
|
||||
release = [ ];
|
||||
release = [
|
||||
{
|
||||
run = ''
|
||||
sed -E -i 's#^([[:space:]]*version[[:space:]]*=[[:space:]]*")[^"]*(",)$#\1'"$FULL_VERSION"'\2#' "$ROOT_DIR/MODULE.bazel"
|
||||
'';
|
||||
}
|
||||
{
|
||||
run = ''
|
||||
README="$ROOT_DIR/README.md"
|
||||
TMP="$README.tmp"
|
||||
|
||||
awk -v stable="$BASE_VERSION" -v prerelease="$BASE_VERSION-rc.1" '
|
||||
{
|
||||
line = $0
|
||||
|
||||
if (line ~ /bazel_dep\(name = "rules_bun", version = "/ && line !~ /-rc\.1/) {
|
||||
sub(/version = "[^"]+"/, "version = \"" stable "\"", line)
|
||||
} else if (line ~ /bazel_dep\(name = "rules_bun", version = "/ && line ~ /-rc\.1/) {
|
||||
sub(/version = "[^"]+"/, "version = \"" prerelease "\"", line)
|
||||
} else if (line ~ /archive\/refs\/tags\/v/ && line !~ /-rc\.1/) {
|
||||
sub(/v[^"]+\.tar\.gz/, "v" stable ".tar.gz", line)
|
||||
} else if (line ~ /archive\/refs\/tags\/v/ && line ~ /-rc\.1/) {
|
||||
sub(/v[^"]+\.tar\.gz/, "v" prerelease ".tar.gz", line)
|
||||
} else if (line ~ /strip_prefix = "rules_bun-v/ && line !~ /-rc\.1/) {
|
||||
sub(/rules_bun-v[^"]+/, "rules_bun-v" stable, line)
|
||||
} else if (line ~ /strip_prefix = "rules_bun-v/ && line ~ /-rc\.1/) {
|
||||
sub(/rules_bun-v[^"]+/, "rules_bun-v" prerelease, line)
|
||||
} else if (line ~ /For channel\/pre-release tags \(for example `v.*-rc\.1`\), use the matching folder prefix:/) {
|
||||
sub(/`v[^`]+`/, "`v" prerelease "`", line)
|
||||
}
|
||||
|
||||
print line
|
||||
}
|
||||
' "$README" > "$TMP" && mv "$TMP" "$README"
|
||||
'';
|
||||
}
|
||||
];
|
||||
|
||||
postVersion = ''
|
||||
echo "Released $FULL_TAG"
|
||||
|
||||
@@ -1,9 +1,45 @@
|
||||
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
exports_files([
|
||||
"bun_binary.bzl",
|
||||
"bun_bundle.bzl",
|
||||
"bun_dev.bzl",
|
||||
"bun_install.bzl",
|
||||
"bun_script.bzl",
|
||||
"bun_test.bzl",
|
||||
"js_library.bzl",
|
||||
])
|
||||
|
||||
bzl_library(
|
||||
name = "bun_binary_bzl",
|
||||
srcs = ["bun_binary.bzl"],
|
||||
)
|
||||
|
||||
bzl_library(
|
||||
name = "bun_bundle_bzl",
|
||||
srcs = ["bun_bundle.bzl"],
|
||||
deps = [":js_library_bzl"],
|
||||
)
|
||||
|
||||
bzl_library(
|
||||
name = "bun_dev_bzl",
|
||||
srcs = ["bun_dev.bzl"],
|
||||
)
|
||||
|
||||
bzl_library(
|
||||
name = "bun_script_bzl",
|
||||
srcs = ["bun_script.bzl"],
|
||||
)
|
||||
|
||||
bzl_library(
|
||||
name = "bun_test_bzl",
|
||||
srcs = ["bun_test.bzl"],
|
||||
deps = [":js_library_bzl"],
|
||||
)
|
||||
|
||||
bzl_library(
|
||||
name = "js_library_bzl",
|
||||
srcs = ["js_library.bzl"],
|
||||
)
|
||||
|
||||
@@ -14,13 +14,38 @@ def _bun_binary_impl(ctx):
|
||||
set -euo pipefail
|
||||
|
||||
runfiles_dir="${{RUNFILES_DIR:-$0.runfiles}}"
|
||||
workspace_root="${{runfiles_dir}}/_main"
|
||||
bun_bin="${{runfiles_dir}}/_main/{bun_short_path}"
|
||||
entry_point="${{runfiles_dir}}/_main/{entry_short_path}"
|
||||
|
||||
exec "${{bun_bin}}" run "${{entry_point}}" "$@"
|
||||
resolve_entrypoint_workdir() {{
|
||||
local dir
|
||||
dir="$(dirname "${{entry_point}}")"
|
||||
while [[ "${{dir}}" == "${{workspace_root}}"* ]]; do
|
||||
if [[ -f "${{dir}}/.env" || -f "${{dir}}/package.json" ]]; then
|
||||
echo "${{dir}}"
|
||||
return 0
|
||||
fi
|
||||
if [[ "${{dir}}" == "${{workspace_root}}" ]]; then
|
||||
break
|
||||
fi
|
||||
dir="$(dirname "${{dir}}")"
|
||||
done
|
||||
echo "$(dirname "${{entry_point}}")"
|
||||
}}
|
||||
|
||||
working_dir="{working_dir}"
|
||||
if [[ "${{working_dir}}" == "entry_point" ]]; then
|
||||
cd "$(resolve_entrypoint_workdir)"
|
||||
else
|
||||
cd "${{workspace_root}}"
|
||||
fi
|
||||
|
||||
exec "${{bun_bin}}" --bun run "${{entry_point}}" "$@"
|
||||
""".format(
|
||||
bun_short_path = bun_bin.short_path,
|
||||
entry_short_path = entry_point.short_path,
|
||||
working_dir = ctx.attr.working_dir,
|
||||
),
|
||||
)
|
||||
|
||||
@@ -43,13 +68,28 @@ exec "${{bun_bin}}" run "${{entry_point}}" "$@"
|
||||
|
||||
bun_binary = rule(
|
||||
implementation = _bun_binary_impl,
|
||||
doc = """Runs a JS/TS entry point with Bun as an executable target.
|
||||
|
||||
Use this rule for non-test scripts and CLIs that should run via `bazel run`.
|
||||
""",
|
||||
attrs = {
|
||||
"entry_point": attr.label(
|
||||
mandatory = True,
|
||||
allow_single_file = [".js", ".ts", ".jsx", ".tsx", ".mjs", ".cjs"],
|
||||
doc = "Path to the main JS/TS file to execute.",
|
||||
),
|
||||
"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 program.",
|
||||
),
|
||||
"working_dir": attr.string(
|
||||
default = "workspace",
|
||||
values = ["workspace", "entry_point"],
|
||||
doc = "Working directory at runtime: `workspace` root or nearest `entry_point` ancestor containing `.env`/`package.json`.",
|
||||
),
|
||||
"node_modules": attr.label(),
|
||||
"data": attr.label_list(allow_files = True),
|
||||
},
|
||||
executable = True,
|
||||
toolchains = ["//bun:toolchain_type"],
|
||||
|
||||
@@ -27,6 +27,7 @@ def _bun_bundle_impl(ctx):
|
||||
outputs.append(output)
|
||||
|
||||
args = ctx.actions.args()
|
||||
args.add("--bun")
|
||||
args.add("build")
|
||||
args.add(entry.path)
|
||||
args.add("--outfile")
|
||||
@@ -60,25 +61,47 @@ def _bun_bundle_impl(ctx):
|
||||
|
||||
bun_bundle = rule(
|
||||
implementation = _bun_bundle_impl,
|
||||
doc = """Bundles one or more JS/TS entry points using Bun build.
|
||||
|
||||
Each entry point produces one output JavaScript artifact.
|
||||
""",
|
||||
attrs = {
|
||||
"entry_points": attr.label_list(
|
||||
mandatory = True,
|
||||
allow_files = [".js", ".ts", ".jsx", ".tsx", ".mjs", ".cjs"],
|
||||
doc = "Entry files to bundle.",
|
||||
),
|
||||
"node_modules": attr.label(
|
||||
doc = "Optional label providing Bun/npm package files for resolution.",
|
||||
),
|
||||
"deps": attr.label_list(
|
||||
doc = "Source/library dependencies that provide transitive inputs.",
|
||||
),
|
||||
"data": attr.label_list(
|
||||
allow_files = True,
|
||||
doc = "Additional non-source files needed during bundling.",
|
||||
),
|
||||
"node_modules": attr.label(),
|
||||
"deps": attr.label_list(),
|
||||
"data": attr.label_list(allow_files = True),
|
||||
"target": attr.string(
|
||||
default = "browser",
|
||||
values = ["browser", "node", "bun"],
|
||||
doc = "Bun build target environment.",
|
||||
),
|
||||
"format": attr.string(
|
||||
default = "esm",
|
||||
values = ["esm", "cjs", "iife"],
|
||||
doc = "Output module format.",
|
||||
),
|
||||
"minify": attr.bool(
|
||||
default = False,
|
||||
doc = "If true, minifies bundle output.",
|
||||
),
|
||||
"sourcemap": attr.bool(
|
||||
default = False,
|
||||
doc = "If true, emits source maps.",
|
||||
),
|
||||
"external": attr.string_list(
|
||||
doc = "Package names to treat as externals (not bundled).",
|
||||
),
|
||||
"minify": attr.bool(default = False),
|
||||
"sourcemap": attr.bool(default = False),
|
||||
"external": attr.string_list(),
|
||||
},
|
||||
toolchains = ["//bun:toolchain_type"],
|
||||
)
|
||||
|
||||
186
internal/bun_dev.bzl
Normal file
186
internal/bun_dev.bzl
Normal file
@@ -0,0 +1,186 @@
|
||||
"""Rule for running JS/TS scripts with Bun in watch mode for development."""
|
||||
|
||||
def _bun_dev_impl(ctx):
|
||||
toolchain = ctx.toolchains["//bun:toolchain_type"]
|
||||
bun_bin = toolchain.bun.bun_bin
|
||||
entry_point = ctx.file.entry_point
|
||||
|
||||
restart_watch_paths = "\n".join([path.short_path for path in ctx.files.restart_on])
|
||||
|
||||
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}"
|
||||
entry_point="${{runfiles_dir}}/_main/{entry_short_path}"
|
||||
|
||||
resolve_entrypoint_workdir() {{
|
||||
local dir
|
||||
dir="$(dirname "${{entry_point}}")"
|
||||
while [[ "${{dir}}" == "${{workspace_root}}"* ]]; do
|
||||
if [[ -f "${{dir}}/.env" || -f "${{dir}}/package.json" ]]; then
|
||||
echo "${{dir}}"
|
||||
return 0
|
||||
fi
|
||||
if [[ "${{dir}}" == "${{workspace_root}}" ]]; then
|
||||
break
|
||||
fi
|
||||
dir="$(dirname "${{dir}}")"
|
||||
done
|
||||
echo "$(dirname "${{entry_point}}")"
|
||||
}}
|
||||
|
||||
working_dir="{working_dir}"
|
||||
if [[ "${{working_dir}}" == "entry_point" ]]; then
|
||||
cd "$(resolve_entrypoint_workdir)"
|
||||
else
|
||||
cd "${{workspace_root}}"
|
||||
fi
|
||||
|
||||
watch_mode="{watch_mode}"
|
||||
if [[ "${{watch_mode}}" == "hot" ]]; then
|
||||
dev_flag="--hot"
|
||||
else
|
||||
dev_flag="--watch"
|
||||
fi
|
||||
|
||||
run_dev() {{
|
||||
exec "${{bun_bin}}" --bun "${{dev_flag}}" run "${{entry_point}}" "$@"
|
||||
}}
|
||||
|
||||
if [[ {restart_count} -eq 0 ]]; then
|
||||
run_dev "$@"
|
||||
fi
|
||||
|
||||
readarray -t restart_paths <<'EOF_RESTART_PATHS'
|
||||
{restart_watch_paths}
|
||||
EOF_RESTART_PATHS
|
||||
|
||||
file_mtime() {{
|
||||
local p="$1"
|
||||
if stat -f '%m' "${{p}}" >/dev/null 2>&1; then
|
||||
stat -f '%m' "${{p}}"
|
||||
return 0
|
||||
fi
|
||||
stat -c '%Y' "${{p}}"
|
||||
}}
|
||||
|
||||
declare -A mtimes
|
||||
for rel in "${{restart_paths[@]}}"; do
|
||||
path="${{runfiles_dir}}/_main/${{rel}}"
|
||||
if [[ -e "${{path}}" ]]; then
|
||||
mtimes["${{rel}}"]="$(file_mtime "${{path}}")"
|
||||
else
|
||||
mtimes["${{rel}}"]="missing"
|
||||
fi
|
||||
done
|
||||
|
||||
child_pid=""
|
||||
restart_child() {{
|
||||
if [[ -n "${{child_pid}}" ]] && kill -0 "${{child_pid}}" 2>/dev/null; then
|
||||
kill "${{child_pid}}"
|
||||
wait "${{child_pid}}" || true
|
||||
fi
|
||||
"${{bun_bin}}" --bun "${{dev_flag}}" run "${{entry_point}}" "$@" &
|
||||
child_pid=$!
|
||||
}}
|
||||
|
||||
cleanup() {{
|
||||
if [[ -n "${{child_pid}}" ]] && kill -0 "${{child_pid}}" 2>/dev/null; then
|
||||
kill "${{child_pid}}"
|
||||
wait "${{child_pid}}" || true
|
||||
fi
|
||||
}}
|
||||
|
||||
trap cleanup EXIT INT TERM
|
||||
|
||||
restart_child "$@"
|
||||
|
||||
while true; do
|
||||
sleep 1
|
||||
changed=0
|
||||
for rel in "${{restart_paths[@]}}"; do
|
||||
path="${{runfiles_dir}}/_main/${{rel}}"
|
||||
if [[ -e "${{path}}" ]]; then
|
||||
current="$(file_mtime "${{path}}")"
|
||||
else
|
||||
current="missing"
|
||||
fi
|
||||
if [[ "${{current}}" != "${{mtimes[${{rel}}]}}" ]]; then
|
||||
mtimes["${{rel}}"]="${{current}}"
|
||||
changed=1
|
||||
fi
|
||||
done
|
||||
if [[ "${{changed}}" -eq 1 ]]; then
|
||||
restart_child "$@"
|
||||
fi
|
||||
done
|
||||
""".format(
|
||||
bun_short_path = bun_bin.short_path,
|
||||
entry_short_path = entry_point.short_path,
|
||||
watch_mode = ctx.attr.watch_mode,
|
||||
working_dir = ctx.attr.working_dir,
|
||||
restart_count = len(ctx.files.restart_on),
|
||||
restart_watch_paths = restart_watch_paths,
|
||||
),
|
||||
)
|
||||
|
||||
transitive_files = []
|
||||
if ctx.attr.node_modules:
|
||||
transitive_files.append(ctx.attr.node_modules[DefaultInfo].files)
|
||||
|
||||
runfiles = ctx.runfiles(
|
||||
files = [bun_bin, entry_point] + ctx.files.data + ctx.files.restart_on,
|
||||
transitive_files = depset(transitive = transitive_files),
|
||||
)
|
||||
|
||||
return [
|
||||
DefaultInfo(
|
||||
executable = launcher,
|
||||
runfiles = runfiles,
|
||||
),
|
||||
]
|
||||
|
||||
bun_dev = rule(
|
||||
implementation = _bun_dev_impl,
|
||||
doc = """Runs a JS/TS entry point in Bun development watch mode.
|
||||
|
||||
This rule is intended for local dev loops (`bazel run`) and supports Bun
|
||||
watch/HMR plus optional full restarts on selected file changes.
|
||||
""",
|
||||
attrs = {
|
||||
"entry_point": attr.label(
|
||||
mandatory = True,
|
||||
allow_single_file = [".js", ".ts", ".jsx", ".tsx", ".mjs", ".cjs"],
|
||||
doc = "Path to the main JS/TS file to execute in dev mode.",
|
||||
),
|
||||
"watch_mode": attr.string(
|
||||
default = "watch",
|
||||
values = ["watch", "hot"],
|
||||
doc = "Bun live-reload mode: `watch` (default) or `hot`.",
|
||||
),
|
||||
"restart_on": attr.label_list(
|
||||
allow_files = True,
|
||||
doc = "Files that trigger a full Bun process restart when they change.",
|
||||
),
|
||||
"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 dev process.",
|
||||
),
|
||||
"working_dir": attr.string(
|
||||
default = "workspace",
|
||||
values = ["workspace", "entry_point"],
|
||||
doc = "Working directory at runtime: `workspace` root or nearest `entry_point` ancestor containing `.env`/`package.json`.",
|
||||
),
|
||||
},
|
||||
executable = True,
|
||||
toolchains = ["//bun:toolchain_type"],
|
||||
)
|
||||
@@ -19,7 +19,6 @@ 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)
|
||||
@@ -31,19 +30,23 @@ def _bun_install_repository_impl(repository_ctx):
|
||||
fail("bun_install: bun_lockfile not found: {}".format(repository_ctx.attr.bun_lockfile))
|
||||
|
||||
bun_bin = _select_bun_binary(repository_ctx)
|
||||
lockfile_name = bun_lockfile.basename
|
||||
|
||||
if lockfile_name not in ["bun.lock", "bun.lockb"]:
|
||||
lockfile_name = "bun.lock"
|
||||
|
||||
repository_ctx.symlink(package_json, "package.json")
|
||||
repository_ctx.symlink(bun_lockfile, "bun.lockb")
|
||||
repository_ctx.symlink(bun_lockfile, lockfile_name)
|
||||
|
||||
result = repository_ctx.execute(
|
||||
[str(bun_bin), "install", "--frozen-lockfile", "--no-progress"],
|
||||
[str(bun_bin), "--bun", "install", "--frozen-lockfile", "--no-progress"],
|
||||
timeout = 600,
|
||||
quiet = False,
|
||||
environment = {"HOME": str(repository_ctx.path("."))},
|
||||
)
|
||||
|
||||
if result.return_code:
|
||||
fail("""bun_install failed running `bun install --frozen-lockfile`.
|
||||
fail("""bun_install failed running `bun --bun install --frozen-lockfile`.
|
||||
stdout:
|
||||
{}
|
||||
stderr:
|
||||
@@ -60,23 +63,19 @@ stderr:
|
||||
""",
|
||||
)
|
||||
|
||||
|
||||
bun_install_repository = repository_rule(
|
||||
implementation = _bun_install_repository_impl,
|
||||
attrs = {
|
||||
"package_json": attr.label(mandatory = True, allow_single_file = True),
|
||||
"bun_lockfile": attr.label(mandatory = True, allow_single_file = True),
|
||||
"bun_linux_x64": attr.label(default = "@bun_linux_x64//:bun", allow_single_file = True),
|
||||
"bun_linux_aarch64": attr.label(default = "@bun_linux_aarch64//:bun", allow_single_file = True),
|
||||
"bun_darwin_x64": attr.label(default = "@bun_darwin_x64//:bun", allow_single_file = True),
|
||||
"bun_darwin_aarch64": attr.label(default = "@bun_darwin_aarch64//:bun", allow_single_file = True),
|
||||
"bun_windows_x64": attr.label(default = "@bun_windows_x64//:bun", allow_single_file = True),
|
||||
"bun_linux_x64": attr.label(default = "@bun_linux_x64//:bun-linux-x64/bun", allow_single_file = True),
|
||||
"bun_linux_aarch64": attr.label(default = "@bun_linux_aarch64//:bun-linux-aarch64/bun", allow_single_file = True),
|
||||
"bun_darwin_x64": attr.label(default = "@bun_darwin_x64//:bun-darwin-x64/bun", allow_single_file = True),
|
||||
"bun_darwin_aarch64": attr.label(default = "@bun_darwin_aarch64//:bun-darwin-aarch64/bun", allow_single_file = True),
|
||||
"bun_windows_x64": attr.label(default = "@bun_windows_x64//:bun-windows-x64/bun.exe", allow_single_file = True),
|
||||
},
|
||||
)
|
||||
|
||||
_bun_install_repository = bun_install_repository
|
||||
|
||||
|
||||
def bun_install(name, package_json, bun_lockfile):
|
||||
"""Create an external repository containing installed node_modules.
|
||||
|
||||
|
||||
103
internal/bun_script.bzl
Normal file
103
internal/bun_script.bzl
Normal file
@@ -0,0 +1,103 @@
|
||||
"""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}}")"
|
||||
|
||||
node_modules_bin_dirs=()
|
||||
while IFS= read -r node_modules_bin; do
|
||||
node_modules_bin_dirs+=("${{node_modules_bin}}")
|
||||
done < <(find "${{runfiles_dir}}" -type d -path '*/node_modules/.bin' 2>/dev/null | sort)
|
||||
|
||||
if [[ ${{#node_modules_bin_dirs[@]}} -gt 0 ]]; then
|
||||
export PATH="$(IFS=:; echo "${{node_modules_bin_dirs[*]}}"):${{PATH}}"
|
||||
fi
|
||||
|
||||
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. This is a good fit
|
||||
for Vite-style workflows, where scripts like `vite dev` or `vite build` are
|
||||
declared in `package.json` and expect to run from the package directory with
|
||||
`node_modules/.bin` available on `PATH`.
|
||||
""",
|
||||
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. Executables from `node_modules/.bin` are added to `PATH`, which is useful for scripts such as `vite`.",
|
||||
),
|
||||
"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`. The default `package` mode matches tools such as Vite that resolve config and assets relative to the package directory.",
|
||||
),
|
||||
},
|
||||
executable = True,
|
||||
toolchains = ["//bun:toolchain_type"],
|
||||
)
|
||||
@@ -24,15 +24,15 @@ bun_bin="${{runfiles_dir}}/_main/{bun_short_path}"
|
||||
cd "${{runfiles_dir}}/_main"
|
||||
|
||||
if [[ -n "${{TESTBRIDGE_TEST_ONLY:-}}" && -n "${{COVERAGE_DIR:-}}" ]]; then
|
||||
exec "${{bun_bin}}" test {src_args} --test-name-pattern "${{TESTBRIDGE_TEST_ONLY}}" --coverage "$@"
|
||||
exec "${{bun_bin}}" --bun test {src_args} --test-name-pattern "${{TESTBRIDGE_TEST_ONLY}}" --coverage "$@"
|
||||
fi
|
||||
if [[ -n "${{TESTBRIDGE_TEST_ONLY:-}}" ]]; then
|
||||
exec "${{bun_bin}}" test {src_args} --test-name-pattern "${{TESTBRIDGE_TEST_ONLY}}" "$@"
|
||||
exec "${{bun_bin}}" --bun test {src_args} --test-name-pattern "${{TESTBRIDGE_TEST_ONLY}}" "$@"
|
||||
fi
|
||||
if [[ -n "${{COVERAGE_DIR:-}}" ]]; then
|
||||
exec "${{bun_bin}}" test {src_args} --coverage "$@"
|
||||
exec "${{bun_bin}}" --bun test {src_args} --coverage "$@"
|
||||
fi
|
||||
exec "${{bun_bin}}" test {src_args} "$@"
|
||||
exec "${{bun_bin}}" --bun test {src_args} "$@"
|
||||
""".format(
|
||||
bun_short_path = bun_bin.short_path,
|
||||
src_args = src_args,
|
||||
@@ -63,14 +63,26 @@ exec "${{bun_bin}}" test {src_args} "$@"
|
||||
|
||||
bun_test = rule(
|
||||
implementation = _bun_test_impl,
|
||||
doc = """Runs Bun tests as a Bazel test target.
|
||||
|
||||
Supports Bazel test filtering (`--test_filter`) and coverage integration.
|
||||
""",
|
||||
attrs = {
|
||||
"srcs": attr.label_list(
|
||||
mandatory = True,
|
||||
allow_files = [".js", ".ts", ".jsx", ".tsx", ".mjs", ".cjs"],
|
||||
doc = "Test source files passed to `bun test`.",
|
||||
),
|
||||
"node_modules": attr.label(
|
||||
doc = "Optional label providing Bun/npm package files in runfiles.",
|
||||
),
|
||||
"deps": attr.label_list(
|
||||
doc = "Library dependencies required by test sources.",
|
||||
),
|
||||
"data": attr.label_list(
|
||||
allow_files = True,
|
||||
doc = "Additional runtime files needed by tests.",
|
||||
),
|
||||
"node_modules": attr.label(),
|
||||
"deps": attr.label_list(),
|
||||
"data": attr.label_list(allow_files = True),
|
||||
},
|
||||
test = True,
|
||||
toolchains = ["//bun:toolchain_type"],
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
"""Lightweight JS/TS source grouping rules."""
|
||||
|
||||
BunSourcesInfo = provider(fields = ["transitive_sources"])
|
||||
|
||||
BunSourcesInfo = provider(
|
||||
"Provides transitive sources for Bun libraries.",
|
||||
fields = ["transitive_sources"],
|
||||
)
|
||||
|
||||
def _bun_library_impl(ctx):
|
||||
transitive_sources = [
|
||||
@@ -18,23 +20,30 @@ 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.",
|
||||
attrs = {
|
||||
"srcs": attr.label_list(
|
||||
allow_files = [".js", ".jsx", ".mjs", ".cjs"],
|
||||
doc = "JavaScript source files in this library.",
|
||||
),
|
||||
"deps": attr.label_list(
|
||||
doc = "Other Bun source libraries to include transitively.",
|
||||
),
|
||||
"deps": attr.label_list(),
|
||||
},
|
||||
)
|
||||
|
||||
ts_library = rule(
|
||||
implementation = _bun_library_impl,
|
||||
doc = "Aggregates TypeScript sources and transitive Bun source dependencies.",
|
||||
attrs = {
|
||||
"srcs": attr.label_list(
|
||||
allow_files = [".ts", ".tsx"],
|
||||
doc = "TypeScript source files in this library.",
|
||||
),
|
||||
"deps": attr.label_list(
|
||||
doc = "Other Bun source libraries to include transitively.",
|
||||
),
|
||||
"deps": attr.label_list(),
|
||||
},
|
||||
)
|
||||
|
||||
@@ -43,3 +43,31 @@ sh_test(
|
||||
"//tests/binary_test:BUILD.bazel",
|
||||
],
|
||||
)
|
||||
|
||||
bun_binary(
|
||||
name = "env_cwd_bin",
|
||||
entry_point = "env.ts",
|
||||
data = [".env"],
|
||||
working_dir = "entry_point",
|
||||
)
|
||||
|
||||
sh_test(
|
||||
name = "bun_binary_env_cwd_test",
|
||||
srcs = ["run_env_binary.sh"],
|
||||
args = ["$(location :env_cwd_bin)"],
|
||||
data = [":env_cwd_bin"],
|
||||
)
|
||||
|
||||
bun_binary(
|
||||
name = "env_parent_cwd_bin",
|
||||
entry_point = "env_parent/src/main.ts",
|
||||
data = ["env_parent/.env"],
|
||||
working_dir = "entry_point",
|
||||
)
|
||||
|
||||
sh_test(
|
||||
name = "bun_binary_env_parent_cwd_test",
|
||||
srcs = ["run_parent_env_binary.sh"],
|
||||
args = ["$(location :env_parent_cwd_bin)"],
|
||||
data = [":env_parent_cwd_bin"],
|
||||
)
|
||||
|
||||
2
tests/binary_test/env.ts
Normal file
2
tests/binary_test/env.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
const value = process.env.BUN_ENV_CWD_TEST ?? "missing";
|
||||
console.log(value);
|
||||
2
tests/binary_test/env_parent/src/main.ts
Normal file
2
tests/binary_test/env_parent/src/main.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
const value = process.env.BUN_ENV_PARENT_TEST ?? "missing";
|
||||
console.log(value);
|
||||
10
tests/binary_test/run_env_binary.sh
Executable file
10
tests/binary_test/run_env_binary.sh
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
binary="$1"
|
||||
output="$(${binary})"
|
||||
|
||||
if [[ ${output} != "from-dotenv" ]]; then
|
||||
echo "Expected .env value from entry-point directory, got: ${output}" >&2
|
||||
exit 1
|
||||
fi
|
||||
10
tests/binary_test/run_parent_env_binary.sh
Executable file
10
tests/binary_test/run_parent_env_binary.sh
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
binary="$1"
|
||||
output="$(${binary})"
|
||||
|
||||
if [[ ${output} != "from-parent-dotenv" ]]; then
|
||||
echo "Expected .env value from parent directory, got: ${output}" >&2
|
||||
exit 1
|
||||
fi
|
||||
@@ -5,4 +5,4 @@ rule_file="$1"
|
||||
|
||||
grep -Fq 'set -euo pipefail' "${rule_file}"
|
||||
grep -Fq 'src_args = " ".join([_shell_quote(src.short_path) for src in ctx.files.srcs])' "${rule_file}"
|
||||
grep -Fq 'exec "${{bun_bin}}" test {src_args} "$@"' "${rule_file}"
|
||||
grep -Fq 'exec "${{bun_bin}}" --bun test {src_args} "$@"' "${rule_file}"
|
||||
|
||||
@@ -3,5 +3,5 @@ set -euo pipefail
|
||||
|
||||
rule_file="$1"
|
||||
|
||||
grep -Fq 'exec "${{bun_bin}}" test {src_args} --test-name-pattern "${{TESTBRIDGE_TEST_ONLY}}" "$@"' "${rule_file}"
|
||||
grep -Fq 'exec "${{bun_bin}}" --bun test {src_args} --test-name-pattern "${{TESTBRIDGE_TEST_ONLY}}" "$@"' "${rule_file}"
|
||||
grep -Fq 'if [[ -n "${{TESTBRIDGE_TEST_ONLY:-}}" ]]' "${rule_file}"
|
||||
|
||||
@@ -5,5 +5,7 @@ rule_file="$1"
|
||||
|
||||
grep -Eq 'install", "--frozen-lockfile", "--no-progress"' "${rule_file}"
|
||||
grep -Eq 'repository_ctx\.symlink\(package_json, "package\.json"\)' "${rule_file}"
|
||||
grep -Eq 'repository_ctx\.symlink\(bun_lockfile, "bun\.lockb"\)' "${rule_file}"
|
||||
grep -Eq 'lockfile_name = bun_lockfile\.basename' "${rule_file}"
|
||||
grep -Eq 'if lockfile_name not in \["bun\.lock", "bun\.lockb"\]:' "${rule_file}"
|
||||
grep -Eq 'repository_ctx\.symlink\(bun_lockfile, lockfile_name\)' "${rule_file}"
|
||||
grep -Eq 'glob\(\["node_modules/\*\*"\]' "${rule_file}"
|
||||
|
||||
51
tests/script_test/BUILD.bazel
Normal file
51
tests/script_test/BUILD.bazel
Normal file
@@ -0,0 +1,51 @@
|
||||
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"],
|
||||
)
|
||||
|
||||
bun_script(
|
||||
name = "vite_dev_server",
|
||||
script = "dev",
|
||||
package_json = "vite_app/package.json",
|
||||
node_modules = "@script_test_vite_node_modules//:node_modules",
|
||||
data = [
|
||||
"vite_app/index.html",
|
||||
"vite_app/main.js",
|
||||
],
|
||||
)
|
||||
|
||||
sh_test(
|
||||
name = "bun_script_vite_app_test",
|
||||
srcs = ["run_vite_app.sh"],
|
||||
args = ["$(location :vite_dev_server)"],
|
||||
data = [":vite_dev_server"],
|
||||
)
|
||||
2
tests/script_test/env.ts
Normal file
2
tests/script_test/env.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
const value = import.meta.env.BUN_SCRIPT_ENV_TEST ?? "missing";
|
||||
console.log(value);
|
||||
1
tests/script_test/hello.ts
Normal file
1
tests/script_test/hello.ts
Normal file
@@ -0,0 +1 @@
|
||||
console.log("hello-script");
|
||||
12
tests/script_test/package.json
Normal file
12
tests/script_test/package.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"name": "script-test",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"hello": "bun ./hello.ts",
|
||||
"print-env": "bun ./env.ts"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/bun": "^1.3.10"
|
||||
}
|
||||
}
|
||||
10
tests/script_test/run_env_script.sh
Executable file
10
tests/script_test/run_env_script.sh
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/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
|
||||
11
tests/script_test/run_script.sh
Executable file
11
tests/script_test/run_script.sh
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/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
|
||||
54
tests/script_test/run_vite_app.sh
Executable file
54
tests/script_test/run_vite_app.sh
Executable file
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
binary="$1"
|
||||
workdir="$(mktemp -d)"
|
||||
log_file="${workdir}/vite.log"
|
||||
|
||||
cleanup() {
|
||||
if [[ -n ${server_pid:-} ]] && kill -0 "${server_pid}" 2>/dev/null; then
|
||||
kill "${server_pid}" 2>/dev/null || true
|
||||
wait "${server_pid}" 2>/dev/null || true
|
||||
fi
|
||||
rm -rf "${workdir}"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
port="$(
|
||||
python3 - <<'PY'
|
||||
import socket
|
||||
sock = socket.socket()
|
||||
sock.bind(("127.0.0.1", 0))
|
||||
print(sock.getsockname()[1])
|
||||
sock.close()
|
||||
PY
|
||||
)"
|
||||
|
||||
"${binary}" --host 127.0.0.1 --port "${port}" --strictPort >"${log_file}" 2>&1 &
|
||||
server_pid=$!
|
||||
|
||||
for _ in {1..60}; do
|
||||
if ! kill -0 "${server_pid}" 2>/dev/null; then
|
||||
cat "${log_file}" >&2
|
||||
echo "Vite server exited unexpectedly" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if curl --fail --silent "http://127.0.0.1:${port}/" | grep -Fq "Vite via bun_script"; then
|
||||
break
|
||||
fi
|
||||
|
||||
sleep 0.5
|
||||
done
|
||||
|
||||
if ! curl --fail --silent "http://127.0.0.1:${port}/" | grep -Fq "Vite via bun_script"; then
|
||||
cat "${log_file}" >&2
|
||||
echo "Timed out waiting for Vite index page" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! curl --fail --silent "http://127.0.0.1:${port}/main.js" | grep -Fq "Hello from Vite"; then
|
||||
cat "${log_file}" >&2
|
||||
echo "Expected Vite module output was not served" >&2
|
||||
exit 1
|
||||
fi
|
||||
127
tests/script_test/vite_app/bun.lock
Normal file
127
tests/script_test/vite_app/bun.lock
Normal file
@@ -0,0 +1,127 @@
|
||||
{
|
||||
"lockfileVersion": 1,
|
||||
"configVersion": 1,
|
||||
"workspaces": {
|
||||
"": {
|
||||
"name": "vite-app-test",
|
||||
"devDependencies": {
|
||||
"vite": "5.4.14",
|
||||
},
|
||||
},
|
||||
},
|
||||
"packages": {
|
||||
"@esbuild/aix-ppc64": ["@esbuild/aix-ppc64@0.21.5", "", { "os": "aix", "cpu": "ppc64" }, "sha512-1SDgH6ZSPTlggy1yI6+Dbkiz8xzpHJEVAlF/AM1tHPLsf5STom9rwtjE4hKAF20FfXXNTFqEYXyJNWh1GiZedQ=="],
|
||||
|
||||
"@esbuild/android-arm": ["@esbuild/android-arm@0.21.5", "", { "os": "android", "cpu": "arm" }, "sha512-vCPvzSjpPHEi1siZdlvAlsPxXl7WbOVUBBAowWug4rJHb68Ox8KualB+1ocNvT5fjv6wpkX6o/iEpbDrf68zcg=="],
|
||||
|
||||
"@esbuild/android-arm64": ["@esbuild/android-arm64@0.21.5", "", { "os": "android", "cpu": "arm64" }, "sha512-c0uX9VAUBQ7dTDCjq+wdyGLowMdtR/GoC2U5IYk/7D1H1JYC0qseD7+11iMP2mRLN9RcCMRcjC4YMclCzGwS/A=="],
|
||||
|
||||
"@esbuild/android-x64": ["@esbuild/android-x64@0.21.5", "", { "os": "android", "cpu": "x64" }, "sha512-D7aPRUUNHRBwHxzxRvp856rjUHRFW1SdQATKXH2hqA0kAZb1hKmi02OpYRacl0TxIGz/ZmXWlbZgjwWYaCakTA=="],
|
||||
|
||||
"@esbuild/darwin-arm64": ["@esbuild/darwin-arm64@0.21.5", "", { "os": "darwin", "cpu": "arm64" }, "sha512-DwqXqZyuk5AiWWf3UfLiRDJ5EDd49zg6O9wclZ7kUMv2WRFr4HKjXp/5t8JZ11QbQfUS6/cRCKGwYhtNAY88kQ=="],
|
||||
|
||||
"@esbuild/darwin-x64": ["@esbuild/darwin-x64@0.21.5", "", { "os": "darwin", "cpu": "x64" }, "sha512-se/JjF8NlmKVG4kNIuyWMV/22ZaerB+qaSi5MdrXtd6R08kvs2qCN4C09miupktDitvh8jRFflwGFBQcxZRjbw=="],
|
||||
|
||||
"@esbuild/freebsd-arm64": ["@esbuild/freebsd-arm64@0.21.5", "", { "os": "freebsd", "cpu": "arm64" }, "sha512-5JcRxxRDUJLX8JXp/wcBCy3pENnCgBR9bN6JsY4OmhfUtIHe3ZW0mawA7+RDAcMLrMIZaf03NlQiX9DGyB8h4g=="],
|
||||
|
||||
"@esbuild/freebsd-x64": ["@esbuild/freebsd-x64@0.21.5", "", { "os": "freebsd", "cpu": "x64" }, "sha512-J95kNBj1zkbMXtHVH29bBriQygMXqoVQOQYA+ISs0/2l3T9/kj42ow2mpqerRBxDJnmkUDCaQT/dfNXWX/ZZCQ=="],
|
||||
|
||||
"@esbuild/linux-arm": ["@esbuild/linux-arm@0.21.5", "", { "os": "linux", "cpu": "arm" }, "sha512-bPb5AHZtbeNGjCKVZ9UGqGwo8EUu4cLq68E95A53KlxAPRmUyYv2D6F0uUI65XisGOL1hBP5mTronbgo+0bFcA=="],
|
||||
|
||||
"@esbuild/linux-arm64": ["@esbuild/linux-arm64@0.21.5", "", { "os": "linux", "cpu": "arm64" }, "sha512-ibKvmyYzKsBeX8d8I7MH/TMfWDXBF3db4qM6sy+7re0YXya+K1cem3on9XgdT2EQGMu4hQyZhan7TeQ8XkGp4Q=="],
|
||||
|
||||
"@esbuild/linux-ia32": ["@esbuild/linux-ia32@0.21.5", "", { "os": "linux", "cpu": "ia32" }, "sha512-YvjXDqLRqPDl2dvRODYmmhz4rPeVKYvppfGYKSNGdyZkA01046pLWyRKKI3ax8fbJoK5QbxblURkwK/MWY18Tg=="],
|
||||
|
||||
"@esbuild/linux-loong64": ["@esbuild/linux-loong64@0.21.5", "", { "os": "linux", "cpu": "none" }, "sha512-uHf1BmMG8qEvzdrzAqg2SIG/02+4/DHB6a9Kbya0XDvwDEKCoC8ZRWI5JJvNdUjtciBGFQ5PuBlpEOXQj+JQSg=="],
|
||||
|
||||
"@esbuild/linux-mips64el": ["@esbuild/linux-mips64el@0.21.5", "", { "os": "linux", "cpu": "none" }, "sha512-IajOmO+KJK23bj52dFSNCMsz1QP1DqM6cwLUv3W1QwyxkyIWecfafnI555fvSGqEKwjMXVLokcV5ygHW5b3Jbg=="],
|
||||
|
||||
"@esbuild/linux-ppc64": ["@esbuild/linux-ppc64@0.21.5", "", { "os": "linux", "cpu": "ppc64" }, "sha512-1hHV/Z4OEfMwpLO8rp7CvlhBDnjsC3CttJXIhBi+5Aj5r+MBvy4egg7wCbe//hSsT+RvDAG7s81tAvpL2XAE4w=="],
|
||||
|
||||
"@esbuild/linux-riscv64": ["@esbuild/linux-riscv64@0.21.5", "", { "os": "linux", "cpu": "none" }, "sha512-2HdXDMd9GMgTGrPWnJzP2ALSokE/0O5HhTUvWIbD3YdjME8JwvSCnNGBnTThKGEB91OZhzrJ4qIIxk/SBmyDDA=="],
|
||||
|
||||
"@esbuild/linux-s390x": ["@esbuild/linux-s390x@0.21.5", "", { "os": "linux", "cpu": "s390x" }, "sha512-zus5sxzqBJD3eXxwvjN1yQkRepANgxE9lgOW2qLnmr8ikMTphkjgXu1HR01K4FJg8h1kEEDAqDcZQtbrRnB41A=="],
|
||||
|
||||
"@esbuild/linux-x64": ["@esbuild/linux-x64@0.21.5", "", { "os": "linux", "cpu": "x64" }, "sha512-1rYdTpyv03iycF1+BhzrzQJCdOuAOtaqHTWJZCWvijKD2N5Xu0TtVC8/+1faWqcP9iBCWOmjmhoH94dH82BxPQ=="],
|
||||
|
||||
"@esbuild/netbsd-x64": ["@esbuild/netbsd-x64@0.21.5", "", { "os": "none", "cpu": "x64" }, "sha512-Woi2MXzXjMULccIwMnLciyZH4nCIMpWQAs049KEeMvOcNADVxo0UBIQPfSmxB3CWKedngg7sWZdLvLczpe0tLg=="],
|
||||
|
||||
"@esbuild/openbsd-x64": ["@esbuild/openbsd-x64@0.21.5", "", { "os": "openbsd", "cpu": "x64" }, "sha512-HLNNw99xsvx12lFBUwoT8EVCsSvRNDVxNpjZ7bPn947b8gJPzeHWyNVhFsaerc0n3TsbOINvRP2byTZ5LKezow=="],
|
||||
|
||||
"@esbuild/sunos-x64": ["@esbuild/sunos-x64@0.21.5", "", { "os": "sunos", "cpu": "x64" }, "sha512-6+gjmFpfy0BHU5Tpptkuh8+uw3mnrvgs+dSPQXQOv3ekbordwnzTVEb4qnIvQcYXq6gzkyTnoZ9dZG+D4garKg=="],
|
||||
|
||||
"@esbuild/win32-arm64": ["@esbuild/win32-arm64@0.21.5", "", { "os": "win32", "cpu": "arm64" }, "sha512-Z0gOTd75VvXqyq7nsl93zwahcTROgqvuAcYDUr+vOv8uHhNSKROyU961kgtCD1e95IqPKSQKH7tBTslnS3tA8A=="],
|
||||
|
||||
"@esbuild/win32-ia32": ["@esbuild/win32-ia32@0.21.5", "", { "os": "win32", "cpu": "ia32" }, "sha512-SWXFF1CL2RVNMaVs+BBClwtfZSvDgtL//G/smwAc5oVK/UPu2Gu9tIaRgFmYFFKrmg3SyAjSrElf0TiJ1v8fYA=="],
|
||||
|
||||
"@esbuild/win32-x64": ["@esbuild/win32-x64@0.21.5", "", { "os": "win32", "cpu": "x64" }, "sha512-tQd/1efJuzPC6rCFwEvLtci/xNFcTZknmXs98FYDfGE4wP9ClFV98nyKrzJKVPMhdDnjzLhdUyMX4PsQAPjwIw=="],
|
||||
|
||||
"@rollup/rollup-android-arm-eabi": ["@rollup/rollup-android-arm-eabi@4.59.0", "", { "os": "android", "cpu": "arm" }, "sha512-upnNBkA6ZH2VKGcBj9Fyl9IGNPULcjXRlg0LLeaioQWueH30p6IXtJEbKAgvyv+mJaMxSm1l6xwDXYjpEMiLMg=="],
|
||||
|
||||
"@rollup/rollup-android-arm64": ["@rollup/rollup-android-arm64@4.59.0", "", { "os": "android", "cpu": "arm64" }, "sha512-hZ+Zxj3SySm4A/DylsDKZAeVg0mvi++0PYVceVyX7hemkw7OreKdCvW2oQ3T1FMZvCaQXqOTHb8qmBShoqk69Q=="],
|
||||
|
||||
"@rollup/rollup-darwin-arm64": ["@rollup/rollup-darwin-arm64@4.59.0", "", { "os": "darwin", "cpu": "arm64" }, "sha512-W2Psnbh1J8ZJw0xKAd8zdNgF9HRLkdWwwdWqubSVk0pUuQkoHnv7rx4GiF9rT4t5DIZGAsConRE3AxCdJ4m8rg=="],
|
||||
|
||||
"@rollup/rollup-darwin-x64": ["@rollup/rollup-darwin-x64@4.59.0", "", { "os": "darwin", "cpu": "x64" }, "sha512-ZW2KkwlS4lwTv7ZVsYDiARfFCnSGhzYPdiOU4IM2fDbL+QGlyAbjgSFuqNRbSthybLbIJ915UtZBtmuLrQAT/w=="],
|
||||
|
||||
"@rollup/rollup-freebsd-arm64": ["@rollup/rollup-freebsd-arm64@4.59.0", "", { "os": "freebsd", "cpu": "arm64" }, "sha512-EsKaJ5ytAu9jI3lonzn3BgG8iRBjV4LxZexygcQbpiU0wU0ATxhNVEpXKfUa0pS05gTcSDMKpn3Sx+QB9RlTTA=="],
|
||||
|
||||
"@rollup/rollup-freebsd-x64": ["@rollup/rollup-freebsd-x64@4.59.0", "", { "os": "freebsd", "cpu": "x64" }, "sha512-d3DuZi2KzTMjImrxoHIAODUZYoUUMsuUiY4SRRcJy6NJoZ6iIqWnJu9IScV9jXysyGMVuW+KNzZvBLOcpdl3Vg=="],
|
||||
|
||||
"@rollup/rollup-linux-arm-gnueabihf": ["@rollup/rollup-linux-arm-gnueabihf@4.59.0", "", { "os": "linux", "cpu": "arm" }, "sha512-t4ONHboXi/3E0rT6OZl1pKbl2Vgxf9vJfWgmUoCEVQVxhW6Cw/c8I6hbbu7DAvgp82RKiH7TpLwxnJeKv2pbsw=="],
|
||||
|
||||
"@rollup/rollup-linux-arm-musleabihf": ["@rollup/rollup-linux-arm-musleabihf@4.59.0", "", { "os": "linux", "cpu": "arm" }, "sha512-CikFT7aYPA2ufMD086cVORBYGHffBo4K8MQ4uPS/ZnY54GKj36i196u8U+aDVT2LX4eSMbyHtyOh7D7Zvk2VvA=="],
|
||||
|
||||
"@rollup/rollup-linux-arm64-gnu": ["@rollup/rollup-linux-arm64-gnu@4.59.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-jYgUGk5aLd1nUb1CtQ8E+t5JhLc9x5WdBKew9ZgAXg7DBk0ZHErLHdXM24rfX+bKrFe+Xp5YuJo54I5HFjGDAA=="],
|
||||
|
||||
"@rollup/rollup-linux-arm64-musl": ["@rollup/rollup-linux-arm64-musl@4.59.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-peZRVEdnFWZ5Bh2KeumKG9ty7aCXzzEsHShOZEFiCQlDEepP1dpUl/SrUNXNg13UmZl+gzVDPsiCwnV1uI0RUA=="],
|
||||
|
||||
"@rollup/rollup-linux-loong64-gnu": ["@rollup/rollup-linux-loong64-gnu@4.59.0", "", { "os": "linux", "cpu": "none" }, "sha512-gbUSW/97f7+r4gHy3Jlup8zDG190AuodsWnNiXErp9mT90iCy9NKKU0Xwx5k8VlRAIV2uU9CsMnEFg/xXaOfXg=="],
|
||||
|
||||
"@rollup/rollup-linux-loong64-musl": ["@rollup/rollup-linux-loong64-musl@4.59.0", "", { "os": "linux", "cpu": "none" }, "sha512-yTRONe79E+o0FWFijasoTjtzG9EBedFXJMl888NBEDCDV9I2wGbFFfJQQe63OijbFCUZqxpHz1GzpbtSFikJ4Q=="],
|
||||
|
||||
"@rollup/rollup-linux-ppc64-gnu": ["@rollup/rollup-linux-ppc64-gnu@4.59.0", "", { "os": "linux", "cpu": "ppc64" }, "sha512-sw1o3tfyk12k3OEpRddF68a1unZ5VCN7zoTNtSn2KndUE+ea3m3ROOKRCZxEpmT9nsGnogpFP9x6mnLTCaoLkA=="],
|
||||
|
||||
"@rollup/rollup-linux-ppc64-musl": ["@rollup/rollup-linux-ppc64-musl@4.59.0", "", { "os": "linux", "cpu": "ppc64" }, "sha512-+2kLtQ4xT3AiIxkzFVFXfsmlZiG5FXYW7ZyIIvGA7Bdeuh9Z0aN4hVyXS/G1E9bTP/vqszNIN/pUKCk/BTHsKA=="],
|
||||
|
||||
"@rollup/rollup-linux-riscv64-gnu": ["@rollup/rollup-linux-riscv64-gnu@4.59.0", "", { "os": "linux", "cpu": "none" }, "sha512-NDYMpsXYJJaj+I7UdwIuHHNxXZ/b/N2hR15NyH3m2qAtb/hHPA4g4SuuvrdxetTdndfj9b1WOmy73kcPRoERUg=="],
|
||||
|
||||
"@rollup/rollup-linux-riscv64-musl": ["@rollup/rollup-linux-riscv64-musl@4.59.0", "", { "os": "linux", "cpu": "none" }, "sha512-nLckB8WOqHIf1bhymk+oHxvM9D3tyPndZH8i8+35p/1YiVoVswPid2yLzgX7ZJP0KQvnkhM4H6QZ5m0LzbyIAg=="],
|
||||
|
||||
"@rollup/rollup-linux-s390x-gnu": ["@rollup/rollup-linux-s390x-gnu@4.59.0", "", { "os": "linux", "cpu": "s390x" }, "sha512-oF87Ie3uAIvORFBpwnCvUzdeYUqi2wY6jRFWJAy1qus/udHFYIkplYRW+wo+GRUP4sKzYdmE1Y3+rY5Gc4ZO+w=="],
|
||||
|
||||
"@rollup/rollup-linux-x64-gnu": ["@rollup/rollup-linux-x64-gnu@4.59.0", "", { "os": "linux", "cpu": "x64" }, "sha512-3AHmtQq/ppNuUspKAlvA8HtLybkDflkMuLK4DPo77DfthRb71V84/c4MlWJXixZz4uruIH4uaa07IqoAkG64fg=="],
|
||||
|
||||
"@rollup/rollup-linux-x64-musl": ["@rollup/rollup-linux-x64-musl@4.59.0", "", { "os": "linux", "cpu": "x64" }, "sha512-2UdiwS/9cTAx7qIUZB/fWtToJwvt0Vbo0zmnYt7ED35KPg13Q0ym1g442THLC7VyI6JfYTP4PiSOWyoMdV2/xg=="],
|
||||
|
||||
"@rollup/rollup-openbsd-x64": ["@rollup/rollup-openbsd-x64@4.59.0", "", { "os": "openbsd", "cpu": "x64" }, "sha512-M3bLRAVk6GOwFlPTIxVBSYKUaqfLrn8l0psKinkCFxl4lQvOSz8ZrKDz2gxcBwHFpci0B6rttydI4IpS4IS/jQ=="],
|
||||
|
||||
"@rollup/rollup-openharmony-arm64": ["@rollup/rollup-openharmony-arm64@4.59.0", "", { "os": "none", "cpu": "arm64" }, "sha512-tt9KBJqaqp5i5HUZzoafHZX8b5Q2Fe7UjYERADll83O4fGqJ49O1FsL6LpdzVFQcpwvnyd0i+K/VSwu/o/nWlA=="],
|
||||
|
||||
"@rollup/rollup-win32-arm64-msvc": ["@rollup/rollup-win32-arm64-msvc@4.59.0", "", { "os": "win32", "cpu": "arm64" }, "sha512-V5B6mG7OrGTwnxaNUzZTDTjDS7F75PO1ae6MJYdiMu60sq0CqN5CVeVsbhPxalupvTX8gXVSU9gq+Rx1/hvu6A=="],
|
||||
|
||||
"@rollup/rollup-win32-ia32-msvc": ["@rollup/rollup-win32-ia32-msvc@4.59.0", "", { "os": "win32", "cpu": "ia32" }, "sha512-UKFMHPuM9R0iBegwzKF4y0C4J9u8C6MEJgFuXTBerMk7EJ92GFVFYBfOZaSGLu6COf7FxpQNqhNS4c4icUPqxA=="],
|
||||
|
||||
"@rollup/rollup-win32-x64-gnu": ["@rollup/rollup-win32-x64-gnu@4.59.0", "", { "os": "win32", "cpu": "x64" }, "sha512-laBkYlSS1n2L8fSo1thDNGrCTQMmxjYY5G0WFWjFFYZkKPjsMBsgJfGf4TLxXrF6RyhI60L8TMOjBMvXiTcxeA=="],
|
||||
|
||||
"@rollup/rollup-win32-x64-msvc": ["@rollup/rollup-win32-x64-msvc@4.59.0", "", { "os": "win32", "cpu": "x64" }, "sha512-2HRCml6OztYXyJXAvdDXPKcawukWY2GpR5/nxKp4iBgiO3wcoEGkAaqctIbZcNB6KlUQBIqt8VYkNSj2397EfA=="],
|
||||
|
||||
"@types/estree": ["@types/estree@1.0.8", "", {}, "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w=="],
|
||||
|
||||
"esbuild": ["esbuild@0.21.5", "", { "optionalDependencies": { "@esbuild/aix-ppc64": "0.21.5", "@esbuild/android-arm": "0.21.5", "@esbuild/android-arm64": "0.21.5", "@esbuild/android-x64": "0.21.5", "@esbuild/darwin-arm64": "0.21.5", "@esbuild/darwin-x64": "0.21.5", "@esbuild/freebsd-arm64": "0.21.5", "@esbuild/freebsd-x64": "0.21.5", "@esbuild/linux-arm": "0.21.5", "@esbuild/linux-arm64": "0.21.5", "@esbuild/linux-ia32": "0.21.5", "@esbuild/linux-loong64": "0.21.5", "@esbuild/linux-mips64el": "0.21.5", "@esbuild/linux-ppc64": "0.21.5", "@esbuild/linux-riscv64": "0.21.5", "@esbuild/linux-s390x": "0.21.5", "@esbuild/linux-x64": "0.21.5", "@esbuild/netbsd-x64": "0.21.5", "@esbuild/openbsd-x64": "0.21.5", "@esbuild/sunos-x64": "0.21.5", "@esbuild/win32-arm64": "0.21.5", "@esbuild/win32-ia32": "0.21.5", "@esbuild/win32-x64": "0.21.5" }, "bin": { "esbuild": "bin/esbuild" } }, "sha512-mg3OPMV4hXywwpoDxu3Qda5xCKQi+vCTZq8S9J/EpkhB2HzKXq4SNFZE3+NK93JYxc8VMSep+lOUSC/RVKaBqw=="],
|
||||
|
||||
"fsevents": ["fsevents@2.3.3", "", { "os": "darwin" }, "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw=="],
|
||||
|
||||
"nanoid": ["nanoid@3.3.11", "", { "bin": { "nanoid": "bin/nanoid.cjs" } }, "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w=="],
|
||||
|
||||
"picocolors": ["picocolors@1.1.1", "", {}, "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA=="],
|
||||
|
||||
"postcss": ["postcss@8.5.8", "", { "dependencies": { "nanoid": "^3.3.11", "picocolors": "^1.1.1", "source-map-js": "^1.2.1" } }, "sha512-OW/rX8O/jXnm82Ey1k44pObPtdblfiuWnrd8X7GJ7emImCOstunGbXUpp7HdBrFQX6rJzn3sPT397Wp5aCwCHg=="],
|
||||
|
||||
"rollup": ["rollup@4.59.0", "", { "dependencies": { "@types/estree": "1.0.8" }, "optionalDependencies": { "@rollup/rollup-android-arm-eabi": "4.59.0", "@rollup/rollup-android-arm64": "4.59.0", "@rollup/rollup-darwin-arm64": "4.59.0", "@rollup/rollup-darwin-x64": "4.59.0", "@rollup/rollup-freebsd-arm64": "4.59.0", "@rollup/rollup-freebsd-x64": "4.59.0", "@rollup/rollup-linux-arm-gnueabihf": "4.59.0", "@rollup/rollup-linux-arm-musleabihf": "4.59.0", "@rollup/rollup-linux-arm64-gnu": "4.59.0", "@rollup/rollup-linux-arm64-musl": "4.59.0", "@rollup/rollup-linux-loong64-gnu": "4.59.0", "@rollup/rollup-linux-loong64-musl": "4.59.0", "@rollup/rollup-linux-ppc64-gnu": "4.59.0", "@rollup/rollup-linux-ppc64-musl": "4.59.0", "@rollup/rollup-linux-riscv64-gnu": "4.59.0", "@rollup/rollup-linux-riscv64-musl": "4.59.0", "@rollup/rollup-linux-s390x-gnu": "4.59.0", "@rollup/rollup-linux-x64-gnu": "4.59.0", "@rollup/rollup-linux-x64-musl": "4.59.0", "@rollup/rollup-openbsd-x64": "4.59.0", "@rollup/rollup-openharmony-arm64": "4.59.0", "@rollup/rollup-win32-arm64-msvc": "4.59.0", "@rollup/rollup-win32-ia32-msvc": "4.59.0", "@rollup/rollup-win32-x64-gnu": "4.59.0", "@rollup/rollup-win32-x64-msvc": "4.59.0", "fsevents": "~2.3.2" }, "bin": { "rollup": "dist/bin/rollup" } }, "sha512-2oMpl67a3zCH9H79LeMcbDhXW/UmWG/y2zuqnF2jQq5uq9TbM9TVyXvA4+t+ne2IIkBdrLpAaRQAvo7YI/Yyeg=="],
|
||||
|
||||
"source-map-js": ["source-map-js@1.2.1", "", {}, "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA=="],
|
||||
|
||||
"vite": ["vite@5.4.14", "", { "dependencies": { "esbuild": "^0.21.3", "postcss": "^8.4.43", "rollup": "^4.20.0" }, "optionalDependencies": { "fsevents": "~2.3.3" }, "peerDependencies": { "@types/node": "^18.0.0 || >=20.0.0", "less": "*", "lightningcss": "^1.21.0", "sass": "*", "sass-embedded": "*", "stylus": "*", "sugarss": "*", "terser": "^5.4.0" }, "optionalPeers": ["@types/node", "less", "lightningcss", "sass", "sass-embedded", "stylus", "sugarss", "terser"], "bin": { "vite": "bin/vite.js" } }, "sha512-EK5cY7Q1D8JNhSaPKVK4pwBFvaTmZxEnoKXLG/U9gmdDcihQGNzFlgIvaxezFR4glP1LsuiedwMBqCXH3wZccA=="],
|
||||
}
|
||||
}
|
||||
12
tests/script_test/vite_app/index.html
Normal file
12
tests/script_test/vite_app/index.html
Normal file
@@ -0,0 +1,12 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Vite via bun_script</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="/main.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
7
tests/script_test/vite_app/main.js
Normal file
7
tests/script_test/vite_app/main.js
Normal file
@@ -0,0 +1,7 @@
|
||||
const app = document.querySelector("#app");
|
||||
|
||||
if (app) {
|
||||
app.textContent = "Hello from Vite";
|
||||
}
|
||||
|
||||
console.log("Hello from Vite");
|
||||
11
tests/script_test/vite_app/package.json
Normal file
11
tests/script_test/vite_app/package.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "vite-app-test",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite"
|
||||
},
|
||||
"devDependencies": {
|
||||
"vite": "5.4.14"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user