feat: implement phase 5 bun_bundle bootstrap
Co-authored-by: Eriyc <50216491+Eriyc@users.noreply.github.com>
This commit is contained in:
48
tests/bundle_test/BUILD.bazel
Normal file
48
tests/bundle_test/BUILD.bazel
Normal 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",
|
||||
],
|
||||
)
|
||||
5
tests/bundle_test/main.ts
Normal file
5
tests/bundle_test/main.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export function greet(name: string): string {
|
||||
return `Hello ${name}`;
|
||||
}
|
||||
|
||||
console.log(greet("bundle"));
|
||||
14
tests/bundle_test/verify_bundle.sh
Executable file
14
tests/bundle_test/verify_bundle.sh
Executable 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
|
||||
13
tests/bundle_test/verify_minify.sh
Executable file
13
tests/bundle_test/verify_minify.sh
Executable 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
|
||||
Reference in New Issue
Block a user