test: add bun workspace tests
Some checks failed
CI / test (ubuntu-latest, linux-x64) (pull_request) Failing after 31s
CI / test (macos-14, darwin-arm64) (pull_request) Has been cancelled
CI / test (windows-latest, windows) (pull_request) Has been cancelled

This commit is contained in:
eric
2026-03-04 09:53:19 +01:00
parent f9d2c36263
commit 481acd9f84
10 changed files with 108 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
load("//bun:defs.bzl", "bun_bundle", "ts_library")
package(default_visibility = ["//visibility:public"])
exports_files([
"README.md",
"package.json",
"packages/pkg-a/package.json",
"packages/pkg-b/package.json",
])
ts_library(
name = "pkg_a_lib",
srcs = ["packages/pkg-a/index.ts"],
)
bun_bundle(
name = "pkg_b_bundle",
entry_points = ["packages/pkg-b/main.ts"],
deps = [":pkg_a_lib"],
target = "bun",
)

View File

@@ -0,0 +1,14 @@
# workspace example
Minimal Bun workspace-style layout with two packages:
- `@workspace/pkg-a`: exports a string helper
- `@workspace/pkg-b`: imports from `pkg-a` and prints the message
The workspace root also defines a Bun `catalog` pin for `lodash`, and both packages consume it via `"lodash": "catalog:"` to keep versions consistent across packages.
This example demonstrates building a target from a workspace-shaped directory tree with Bazel:
```bash
bazel build //examples/workspace:pkg_b_bundle
```

View File

@@ -0,0 +1,10 @@
{
"name": "workspace-root",
"private": true,
"workspaces": [
"packages/*"
],
"catalog": {
"lodash": "^4.17.21"
}
}

View File

@@ -0,0 +1,3 @@
export function workspaceMessage(): string {
return "workspace-pkg-a";
}

View File

@@ -0,0 +1,8 @@
{
"name": "@workspace/pkg-a",
"version": "1.0.0",
"main": "index.ts",
"dependencies": {
"lodash": "catalog:"
}
}

View File

@@ -0,0 +1,3 @@
import { workspaceMessage } from "../pkg-a/index";
console.log(`hello-${workspaceMessage()}`);

View File

@@ -0,0 +1,8 @@
{
"name": "@workspace/pkg-b",
"version": "1.0.0",
"dependencies": {
"@workspace/pkg-a": "workspace:*",
"lodash": "catalog:"
}
}