Skip to content

Commit 7f68bf3

Browse files
committed
adds test cases
1 parent 69afc93 commit 7f68bf3

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

examples/assets/BUILD.bazel

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
load("@aspect_bazel_lib//lib:copy_to_directory.bzl", "copy_to_directory")
22
load("@aspect_bazel_lib//lib:testing.bzl", "assert_outputs")
3+
load("@aspect_rules_js//js:defs.bzl", "js_test")
34
load("@aspect_rules_ts//ts:defs.bzl", "ts_config", "ts_project")
45
load("@bazel_skylib//rules:build_test.bzl", "build_test")
56

@@ -44,6 +45,34 @@ ts_project(
4445
tsconfig = {"compilerOptions": {"outDir": "out"}},
4546
)
4647

48+
ts_project(
49+
name = "ts-runtime-assets",
50+
srcs = ["src/index-runtime.ts"],
51+
assets = ["src/generated.json"],
52+
tsconfig = ":config",
53+
)
54+
55+
js_test(
56+
name = "ts-runtime-assets_test",
57+
data = [":ts-runtime-assets"],
58+
entry_point = "src/index-runtime.js",
59+
)
60+
61+
ts_project(
62+
name = "ts-runtime-outdir-assets",
63+
srcs = ["src/index-runtime.ts"],
64+
assets = ["src/generated.json"],
65+
extends = ":config",
66+
out_dir = "out",
67+
tsconfig = {"compilerOptions": {"outDir": "out"}},
68+
)
69+
70+
js_test(
71+
name = "ts-runtime-outdir-assets_test",
72+
data = [":ts-runtime-outdir-assets"],
73+
entry_point = "out/src/index-runtime.js",
74+
)
75+
4776
filegroup(
4877
name = "assets-filegroup",
4978
srcs = [
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* This testcase exists to verify assets get propagated correctly. It
3+
* intentionally does not use `import` or `require` for the generated asset to
4+
* more closely mimic what a downstream rule (eg. a bundler) would do.
5+
*/
6+
import * as fs from 'fs'
7+
import * as path from 'path'
8+
9+
const data = fs.readFileSync(path.join(__dirname, 'generated.json'))
10+
11+
console.log(__dirname, data)

0 commit comments

Comments
 (0)