feat: add phase 6 js_library and ts_library bootstrap
This commit is contained in:
committed by
copilot-swe-agent[bot]
parent
a4f6b55d43
commit
8463e94e00
41
tests/library_test/BUILD.bazel
Normal file
41
tests/library_test/BUILD.bazel
Normal file
@@ -0,0 +1,41 @@
|
||||
load("//bun:defs.bzl", "bun_bundle", "bun_test", "ts_library")
|
||||
|
||||
ts_library(
|
||||
name = "helper_lib",
|
||||
srcs = ["helper.ts"],
|
||||
target_compatible_with = [
|
||||
"@platforms//cpu:x86_64",
|
||||
"@platforms//os:linux",
|
||||
],
|
||||
)
|
||||
|
||||
bun_bundle(
|
||||
name = "bundle_with_deps",
|
||||
entry_points = ["app.ts"],
|
||||
deps = [":helper_lib"],
|
||||
target_compatible_with = [
|
||||
"@platforms//cpu:x86_64",
|
||||
"@platforms//os:linux",
|
||||
],
|
||||
)
|
||||
|
||||
sh_test(
|
||||
name = "bundle_dep_propagation_test",
|
||||
srcs = ["verify_bundle.sh"],
|
||||
args = ["$(location :bundle_with_deps)"],
|
||||
data = [":bundle_with_deps"],
|
||||
target_compatible_with = [
|
||||
"@platforms//cpu:x86_64",
|
||||
"@platforms//os:linux",
|
||||
],
|
||||
)
|
||||
|
||||
bun_test(
|
||||
name = "test_with_deps",
|
||||
srcs = ["app.test.ts"],
|
||||
deps = [":helper_lib"],
|
||||
target_compatible_with = [
|
||||
"@platforms//cpu:x86_64",
|
||||
"@platforms//os:linux",
|
||||
],
|
||||
)
|
||||
6
tests/library_test/app.test.ts
Normal file
6
tests/library_test/app.test.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { expect, test } from "bun:test";
|
||||
import { greeting } from "./helper";
|
||||
|
||||
test("uses helper from ts_library dep", () => {
|
||||
expect(greeting("test")).toBe("hello-test");
|
||||
});
|
||||
3
tests/library_test/app.ts
Normal file
3
tests/library_test/app.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import { greeting } from "./helper";
|
||||
|
||||
console.log(greeting("bundle"));
|
||||
3
tests/library_test/helper.ts
Normal file
3
tests/library_test/helper.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export function greeting(name: string): string {
|
||||
return `hello-${name}`;
|
||||
}
|
||||
9
tests/library_test/verify_bundle.sh
Executable file
9
tests/library_test/verify_bundle.sh
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
bundle="$1"
|
||||
|
||||
if [[ ! -s "${bundle}" ]]; then
|
||||
echo "Expected bundled output to exist and be non-empty: ${bundle}" >&2
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user