Compare commits
4 Commits
copilot/ad
...
76a3f2f442
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
76a3f2f442 | ||
|
|
4d1be5ada2 | ||
|
|
cf18ebeb79 | ||
|
|
9b2420c9b9 |
6
.github/workflows/copilot-setup-steps.yml
vendored
6
.github/workflows/copilot-setup-steps.yml
vendored
@@ -35,5 +35,11 @@ jobs:
|
|||||||
extra_nix_config: |
|
extra_nix_config: |
|
||||||
experimental-features = nix-command flakes
|
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
|
- name: Install flake dependencies
|
||||||
run: nix develop --accept-flake-config -c true
|
run: nix develop --accept-flake-config -c true
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
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",
|
|
||||||
)
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
# 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
|
|
||||||
```
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "workspace-root",
|
|
||||||
"private": true,
|
|
||||||
"workspaces": [
|
|
||||||
"packages/*"
|
|
||||||
],
|
|
||||||
"catalog": {
|
|
||||||
"lodash": "^4.17.21"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
export function workspaceMessage(): string {
|
|
||||||
return "workspace-pkg-a";
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "@workspace/pkg-a",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"main": "index.ts",
|
|
||||||
"dependencies": {
|
|
||||||
"lodash": "catalog:"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
import { workspaceMessage } from "../pkg-a/index";
|
|
||||||
|
|
||||||
console.log(`hello-${workspaceMessage()}`);
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "@workspace/pkg-b",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"dependencies": {
|
|
||||||
"@workspace/pkg-a": "workspace:*",
|
|
||||||
"lodash": "catalog:"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
12
flake.lock
generated
12
flake.lock
generated
@@ -9,16 +9,16 @@
|
|||||||
"treefmt-nix": "treefmt-nix"
|
"treefmt-nix": "treefmt-nix"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1772610504,
|
"lastModified": 1772613315,
|
||||||
"narHash": "sha256-uoMnjsab5IpZRZ/1mn5oVy4fRnAYn6b58E3FNa+jyQY=",
|
"narHash": "sha256-RlPTOsyfVwuwEzvaMpwS+giOqQa6KQXMuSHyh1bctjk=",
|
||||||
"ref": "v1.0.4",
|
"ref": "v1.0.5",
|
||||||
"rev": "86a0792b6e54104e8cb33983cabc175aea8da464",
|
"rev": "e445e49baf8b44b385108cd4f26a14d8ccf9fd35",
|
||||||
"revCount": 33,
|
"revCount": 35,
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://git.dgren.dev/eric/nix-flake-lib"
|
"url": "https://git.dgren.dev/eric/nix-flake-lib"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"ref": "v1.0.4",
|
"ref": "v1.0.5",
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://git.dgren.dev/eric/nix-flake-lib"
|
"url": "https://git.dgren.dev/eric/nix-flake-lib"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,12 +3,13 @@
|
|||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
|
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=v1.0.5";
|
||||||
devshell-lib.inputs.nixpkgs.follows = "nixpkgs";
|
devshell-lib.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs =
|
outputs =
|
||||||
{
|
{
|
||||||
|
self,
|
||||||
nixpkgs,
|
nixpkgs,
|
||||||
devshell-lib,
|
devshell-lib,
|
||||||
...
|
...
|
||||||
@@ -41,6 +42,7 @@
|
|||||||
bun
|
bun
|
||||||
bazel9
|
bazel9
|
||||||
bazel-buildtools
|
bazel-buildtools
|
||||||
|
self.packages.${system}.release
|
||||||
];
|
];
|
||||||
|
|
||||||
features = {
|
features = {
|
||||||
@@ -86,7 +88,7 @@
|
|||||||
name = "Bazel";
|
name = "Bazel";
|
||||||
bin = "${bazel9}/bin/bazel";
|
bin = "${bazel9}/bin/bazel";
|
||||||
versionCmd = "--version";
|
versionCmd = "--version";
|
||||||
color = "BLUE";
|
color = "GREEN";
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -76,22 +76,3 @@ sh_test(
|
|||||||
args = ["$(location //internal:bun_install.bzl)"],
|
args = ["$(location //internal:bun_install.bzl)"],
|
||||||
data = ["//internal:bun_install.bzl"],
|
data = ["//internal:bun_install.bzl"],
|
||||||
)
|
)
|
||||||
|
|
||||||
sh_test(
|
|
||||||
name = "bun_install_workspaces_test",
|
|
||||||
srcs = ["workspaces.sh"],
|
|
||||||
args = select({
|
|
||||||
":linux_x86_64": ["$(location @bun_linux_x64//:bun)"],
|
|
||||||
":linux_aarch64": ["$(location @bun_linux_aarch64//:bun)"],
|
|
||||||
":darwin_x86_64": ["$(location @bun_darwin_x64//:bun)"],
|
|
||||||
":darwin_aarch64": ["$(location @bun_darwin_aarch64//:bun)"],
|
|
||||||
"//conditions:default": ["$(location @bun_linux_x64//:bun)"],
|
|
||||||
}),
|
|
||||||
data = select({
|
|
||||||
":linux_x86_64": ["@bun_linux_x64//:bun"],
|
|
||||||
":linux_aarch64": ["@bun_linux_aarch64//:bun"],
|
|
||||||
":darwin_x86_64": ["@bun_darwin_x64//:bun"],
|
|
||||||
":darwin_aarch64": ["@bun_darwin_aarch64//:bun"],
|
|
||||||
"//conditions:default": ["@bun_linux_x64//:bun"],
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
|
|||||||
@@ -1,46 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
bun_path="$1"
|
|
||||||
workdir="$(mktemp -d)"
|
|
||||||
trap 'rm -rf "${workdir}"' EXIT
|
|
||||||
|
|
||||||
mkdir -p "${workdir}/packages/pkg-a" "${workdir}/packages/pkg-b"
|
|
||||||
|
|
||||||
cat >"${workdir}/package.json" <<'JSON'
|
|
||||||
{
|
|
||||||
"name": "workspace-root",
|
|
||||||
"private": true,
|
|
||||||
"workspaces": ["packages/*"]
|
|
||||||
}
|
|
||||||
JSON
|
|
||||||
|
|
||||||
cat >"${workdir}/packages/pkg-a/package.json" <<'JSON'
|
|
||||||
{
|
|
||||||
"name": "@workspace/pkg-a",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"main": "index.js"
|
|
||||||
}
|
|
||||||
JSON
|
|
||||||
|
|
||||||
cat >"${workdir}/packages/pkg-a/index.js" <<'JS'
|
|
||||||
module.exports = { value: 42 };
|
|
||||||
JS
|
|
||||||
|
|
||||||
cat >"${workdir}/packages/pkg-b/package.json" <<'JSON'
|
|
||||||
{
|
|
||||||
"name": "@workspace/pkg-b",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"dependencies": {
|
|
||||||
"@workspace/pkg-a": "workspace:*"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"check": "bun -e \"const { value } = require('@workspace/pkg-a'); if (value !== 42) process.exit(1)\""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
JSON
|
|
||||||
|
|
||||||
"${bun_path}" install --cwd "${workdir}" >/dev/null
|
|
||||||
rm -rf "${workdir}/node_modules" "${workdir}/packages/pkg-b/node_modules"
|
|
||||||
"${bun_path}" install --cwd "${workdir}" --frozen-lockfile >/dev/null
|
|
||||||
"${bun_path}" run --cwd "${workdir}/packages/pkg-b" check >/dev/null
|
|
||||||
@@ -13,28 +13,6 @@ sh_test(
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
sh_test(
|
|
||||||
name = "examples_workspace_bundle_e2e_test",
|
|
||||||
srcs = ["examples_workspace_bundle_e2e_test.sh"],
|
|
||||||
args = ["$(location //examples/workspace:pkg_b_bundle)"],
|
|
||||||
data = ["//examples/workspace:pkg_b_bundle"],
|
|
||||||
)
|
|
||||||
|
|
||||||
sh_test(
|
|
||||||
name = "examples_workspace_catalog_shape_test",
|
|
||||||
srcs = ["examples_workspace_catalog_shape_test.sh"],
|
|
||||||
args = [
|
|
||||||
"$(location //examples/workspace:package.json)",
|
|
||||||
"$(location //examples/workspace:packages/pkg-a/package.json)",
|
|
||||||
"$(location //examples/workspace:packages/pkg-b/package.json)",
|
|
||||||
],
|
|
||||||
data = [
|
|
||||||
"//examples/workspace:package.json",
|
|
||||||
"//examples/workspace:packages/pkg-a/package.json",
|
|
||||||
"//examples/workspace:packages/pkg-b/package.json",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
sh_test(
|
sh_test(
|
||||||
name = "repo_all_targets_test",
|
name = "repo_all_targets_test",
|
||||||
srcs = ["repo_all_targets_test.sh"],
|
srcs = ["repo_all_targets_test.sh"],
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
bundle_file="$1"
|
|
||||||
|
|
||||||
[[ -f ${bundle_file} ]]
|
|
||||||
grep -Eq 'hello-workspace-pkg-a|workspace-pkg-a' "${bundle_file}"
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
root_package_json="$1"
|
|
||||||
pkg_a_package_json="$2"
|
|
||||||
pkg_b_package_json="$3"
|
|
||||||
|
|
||||||
grep -Eq '"catalog"[[:space:]]*:[[:space:]]*\{' "${root_package_json}"
|
|
||||||
grep -Eq '"lodash"[[:space:]]*:[[:space:]]*"\^4\.17\.21"' "${root_package_json}"
|
|
||||||
grep -Eq '"lodash"[[:space:]]*:[[:space:]]*"catalog:"' "${pkg_a_package_json}"
|
|
||||||
grep -Eq '"lodash"[[:space:]]*:[[:space:]]*"catalog:"' "${pkg_b_package_json}"
|
|
||||||
Reference in New Issue
Block a user