fix: bun install symlinks
Some checks failed
CI / test (ubuntu-latest, linux-x64) (push) Failing after 39s
Docs Pages / deploy (push) Failing after 33s
CI / test (macos-14, darwin-arm64) (push) Has been cancelled
CI / test (windows-latest, windows) (push) Has been cancelled

This commit is contained in:
eric
2026-03-07 00:00:00 +01:00
parent 40d621d1cf
commit d04f489b0e
6 changed files with 61 additions and 15 deletions

View File

@@ -1 +1 @@
/nix/store/5lbgsnb4r2d7gdjykl2hiqny0ya64baa-pre-commit-config.json
/nix/store/fj7p8m3p4s7cx9kqvx2h0glk2ygknmvl-pre-commit-config.json

14
MODULE.bazel.lock generated
View File

@@ -253,7 +253,7 @@
},
"//bun:extensions.bzl%bun_install": {
"general": {
"bzlTransitiveDigest": "xKWhaSNvthtzN2J8BNWSLHTqQ5ZJHwyCTQAdUQyOFXE=",
"bzlTransitiveDigest": "64B4fTkEHdAlieIOkE/Wi2M/R9lMNZhFxeI1eXEFHRs=",
"usagesDigest": "d+DGTyl4FpB6Ygb/R/V5knxm9bGYZKO223wMX1Q6R6w=",
"recordedInputs": [
"REPO_MAPPING:,bazel_tools bazel_tools"
@@ -263,21 +263,27 @@
"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"
"bun_lockfile": "@@//tests/script_test:vite_app/bun.lock",
"install_inputs": [],
"isolated_home": true
}
},
"script_test_vite_monorepo_node_modules": {
"repoRuleId": "@@//internal:bun_install.bzl%bun_install_repository",
"attributes": {
"package_json": "@@//tests/script_test:vite_monorepo/package.json",
"bun_lockfile": "@@//tests/script_test:vite_monorepo/bun.lock"
"bun_lockfile": "@@//tests/script_test:vite_monorepo/bun.lock",
"install_inputs": [],
"isolated_home": true
}
},
"examples_vite_monorepo_node_modules": {
"repoRuleId": "@@//internal:bun_install.bzl%bun_install_repository",
"attributes": {
"package_json": "@@//examples/vite_monorepo:package.json",
"bun_lockfile": "@@//examples/vite_monorepo:bun.lock"
"bun_lockfile": "@@//examples/vite_monorepo:bun.lock",
"install_inputs": [],
"isolated_home": true
}
}
}

View File

@@ -4,6 +4,16 @@ load("@rules_bun//bun:defs.bzl", "bun_script")
load("@rules_multirun//:defs.bzl", "multirun")
load("@rules_shell//shell:sh_test.bzl", "sh_test")
package(default_visibility = ["//visibility:public"])
exports_files([
"README.md",
"package.json",
"bun.lock",
"apps/app-a/package.json",
"apps/app-b/package.json",
])
multirun(
name = "dev",
commands = [

View File

@@ -66,8 +66,7 @@
tests = {
enable = true;
entry = ''
bazel test //tests/... --test_output=errors
tests/install_test/workspace_parity.sh "$(command -v bun)"
${pkgs.bash}/bin/bash -ec 'bazel test //tests/... --test_output=errors && tests/install_test/workspace_parity.sh "$(command -v bun)"'
'';
pass_filenames = false;
stages = [ "pre-push" ];

View File

@@ -92,9 +92,40 @@ find_node_modules() {{
return 1
}}
if [[ -n "${{install_repo_root}}" && -d "${{install_repo_root}}/${{package_rel_dir}}/node_modules" ]]; then
find_install_repo_node_modules() {{
local repo_root="$1"
local rel_dir="$2"
local candidate="${{rel_dir}}"
while [[ -n "${{candidate}}" ]]; do
if [[ -d "${{repo_root}}/${{candidate}}/node_modules" ]]; then
echo "${{repo_root}}/${{candidate}}/node_modules"
return 0
fi
if [[ "${{candidate}}" != */* ]]; then
break
fi
candidate="${{candidate#*/}}"
done
if [[ -d "${{repo_root}}/node_modules" ]]; then
echo "${{repo_root}}/node_modules"
return 0
fi
return 1
}}
resolved_install_node_modules=""
if [[ -n "${{install_repo_root}}" ]]; then
resolved_install_node_modules="$(find_install_repo_node_modules "${{install_repo_root}}" "${{package_rel_dir}}" || true)"
fi
if [[ -n "${{resolved_install_node_modules}}" ]]; then
rm -rf "${{runtime_package_dir}}/node_modules"
ln -s "${{install_repo_root}}/${{package_rel_dir}}/node_modules" "${{runtime_package_dir}}/node_modules"
ln -s "${{resolved_install_node_modules}}" "${{runtime_package_dir}}/node_modules"
else
resolved_node_modules="$(find_node_modules "${{runtime_package_dir}}" "${{runtime_workspace}}" || true)"
if [[ -n "${{resolved_node_modules}}" && "${{resolved_node_modules}}" != "${{runtime_package_dir}}/node_modules" ]]; then

View File

@@ -403,17 +403,17 @@ if ! diff -u "${plain_manifest}" "${bazel_manifest}"; then
exit 1
fi
rm -rf "${plain_dir}/packages/web/dist"
"${bun_path}" run --cwd "${plain_dir}/packages/web" build -- --emptyOutDir >/dev/null
plain_dist_dir="${workdir}/plain-dist"
bazel_dist_dir="${workdir}/bazel-dist"
rm -rf "${plain_dist_dir}" "${bazel_dist_dir}"
"${bun_path}" run --cwd "${plain_dir}/packages/web" build -- --emptyOutDir --outDir "${plain_dist_dir}" >/dev/null
(
cd "${bazel_dir}"
bazel run //:web_build -- --emptyOutDir >/dev/null
bazel run //:web_build -- --emptyOutDir --outDir "${bazel_dist_dir}" >/dev/null
)
plain_dist_dir="${plain_dir}/packages/web/dist"
bazel_dist_dir="${bazel_dir}/bazel-bin/web_build.runfiles/_main/packages/web/dist"
if [[ ! -d ${plain_dist_dir} ]]; then
echo "Plain Bun Vite build did not produce output" >&2
exit 1