fix: bun install symlinks
This commit is contained in:
@@ -1 +1 @@
|
|||||||
/nix/store/5lbgsnb4r2d7gdjykl2hiqny0ya64baa-pre-commit-config.json
|
/nix/store/fj7p8m3p4s7cx9kqvx2h0glk2ygknmvl-pre-commit-config.json
|
||||||
14
MODULE.bazel.lock
generated
14
MODULE.bazel.lock
generated
@@ -253,7 +253,7 @@
|
|||||||
},
|
},
|
||||||
"//bun:extensions.bzl%bun_install": {
|
"//bun:extensions.bzl%bun_install": {
|
||||||
"general": {
|
"general": {
|
||||||
"bzlTransitiveDigest": "xKWhaSNvthtzN2J8BNWSLHTqQ5ZJHwyCTQAdUQyOFXE=",
|
"bzlTransitiveDigest": "64B4fTkEHdAlieIOkE/Wi2M/R9lMNZhFxeI1eXEFHRs=",
|
||||||
"usagesDigest": "d+DGTyl4FpB6Ygb/R/V5knxm9bGYZKO223wMX1Q6R6w=",
|
"usagesDigest": "d+DGTyl4FpB6Ygb/R/V5knxm9bGYZKO223wMX1Q6R6w=",
|
||||||
"recordedInputs": [
|
"recordedInputs": [
|
||||||
"REPO_MAPPING:,bazel_tools bazel_tools"
|
"REPO_MAPPING:,bazel_tools bazel_tools"
|
||||||
@@ -263,21 +263,27 @@
|
|||||||
"repoRuleId": "@@//internal:bun_install.bzl%bun_install_repository",
|
"repoRuleId": "@@//internal:bun_install.bzl%bun_install_repository",
|
||||||
"attributes": {
|
"attributes": {
|
||||||
"package_json": "@@//tests/script_test:vite_app/package.json",
|
"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": {
|
"script_test_vite_monorepo_node_modules": {
|
||||||
"repoRuleId": "@@//internal:bun_install.bzl%bun_install_repository",
|
"repoRuleId": "@@//internal:bun_install.bzl%bun_install_repository",
|
||||||
"attributes": {
|
"attributes": {
|
||||||
"package_json": "@@//tests/script_test:vite_monorepo/package.json",
|
"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": {
|
"examples_vite_monorepo_node_modules": {
|
||||||
"repoRuleId": "@@//internal:bun_install.bzl%bun_install_repository",
|
"repoRuleId": "@@//internal:bun_install.bzl%bun_install_repository",
|
||||||
"attributes": {
|
"attributes": {
|
||||||
"package_json": "@@//examples/vite_monorepo:package.json",
|
"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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,16 @@ load("@rules_bun//bun:defs.bzl", "bun_script")
|
|||||||
load("@rules_multirun//:defs.bzl", "multirun")
|
load("@rules_multirun//:defs.bzl", "multirun")
|
||||||
load("@rules_shell//shell:sh_test.bzl", "sh_test")
|
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(
|
multirun(
|
||||||
name = "dev",
|
name = "dev",
|
||||||
commands = [
|
commands = [
|
||||||
|
|||||||
@@ -66,8 +66,7 @@
|
|||||||
tests = {
|
tests = {
|
||||||
enable = true;
|
enable = true;
|
||||||
entry = ''
|
entry = ''
|
||||||
bazel test //tests/... --test_output=errors
|
${pkgs.bash}/bin/bash -ec 'bazel test //tests/... --test_output=errors && tests/install_test/workspace_parity.sh "$(command -v bun)"'
|
||||||
tests/install_test/workspace_parity.sh "$(command -v bun)"
|
|
||||||
'';
|
'';
|
||||||
pass_filenames = false;
|
pass_filenames = false;
|
||||||
stages = [ "pre-push" ];
|
stages = [ "pre-push" ];
|
||||||
|
|||||||
@@ -92,9 +92,40 @@ find_node_modules() {{
|
|||||||
return 1
|
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"
|
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
|
else
|
||||||
resolved_node_modules="$(find_node_modules "${{runtime_package_dir}}" "${{runtime_workspace}}" || true)"
|
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
|
if [[ -n "${{resolved_node_modules}}" && "${{resolved_node_modules}}" != "${{runtime_package_dir}}/node_modules" ]]; then
|
||||||
|
|||||||
@@ -403,17 +403,17 @@ if ! diff -u "${plain_manifest}" "${bazel_manifest}"; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm -rf "${plain_dir}/packages/web/dist"
|
plain_dist_dir="${workdir}/plain-dist"
|
||||||
"${bun_path}" run --cwd "${plain_dir}/packages/web" build -- --emptyOutDir >/dev/null
|
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}"
|
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
|
if [[ ! -d ${plain_dist_dir} ]]; then
|
||||||
echo "Plain Bun Vite build did not produce output" >&2
|
echo "Plain Bun Vite build did not produce output" >&2
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
Reference in New Issue
Block a user