feat: implement phase 5 bun_bundle bootstrap

This commit is contained in:
Eric
2026-03-04 03:30:07 +00:00
committed by eric
parent 21fe4b7b36
commit f534d13c3a
7 changed files with 164 additions and 2 deletions

View File

@@ -0,0 +1,48 @@
load("//bun:defs.bzl", "bun_bundle")
bun_bundle(
name = "simple_bundle",
entry_points = ["main.ts"],
target_compatible_with = [
"@platforms//cpu:x86_64",
"@platforms//os:linux",
],
)
bun_bundle(
name = "minified_bundle",
entry_points = ["main.ts"],
minify = True,
target_compatible_with = [
"@platforms//cpu:x86_64",
"@platforms//os:linux",
],
)
sh_test(
name = "bundle_output_test",
srcs = ["verify_bundle.sh"],
args = ["$(location :simple_bundle)"],
data = [":simple_bundle"],
target_compatible_with = [
"@platforms//cpu:x86_64",
"@platforms//os:linux",
],
)
sh_test(
name = "bundle_minify_test",
srcs = ["verify_minify.sh"],
args = [
"$(location :simple_bundle)",
"$(location :minified_bundle)",
],
data = [
":simple_bundle",
":minified_bundle",
],
target_compatible_with = [
"@platforms//cpu:x86_64",
"@platforms//os:linux",
],
)

View File

@@ -0,0 +1,5 @@
export function greet(name: string): string {
return `Hello ${name}`;
}
console.log(greet("bundle"));

View File

@@ -0,0 +1,14 @@
#!/usr/bin/env bash
set -euo pipefail
bundle="$1"
if [[ ! -f "${bundle}" ]]; then
echo "Bundle output not found: ${bundle}" >&2
exit 1
fi
if [[ ! -s "${bundle}" ]]; then
echo "Bundle output is empty: ${bundle}" >&2
exit 1
fi

View File

@@ -0,0 +1,13 @@
#!/usr/bin/env bash
set -euo pipefail
bundle="$1"
minified="$2"
bundle_size="$(wc -c < "${bundle}")"
minified_size="$(wc -c < "${minified}")"
if (( minified_size >= bundle_size )); then
echo "Expected minified bundle (${minified_size}) to be smaller than regular bundle (${bundle_size})" >&2
exit 1
fi