I'm trying to figure out how to build typescript with Bazel and I cloned this repository:
git clone https://github.com/aspect-build/bazel-examples
And ran the ts_project_transpiler
example.
cd ts_project_transpiler
bazel build //...
And this works. And I want to use a glob pattern so that I can have a directory with more typescript files in it, and it looks like Bazel has functions for this.
So I tried.
ts_project(
name = "tsc",
#srcs = ["big.ts"],
srcs = glob(["*.ts"]),
declaration = True,
declaration_dir = "build-tsc",
out_dir = "build-tsc",
source_map = True,
)
However this errors out.
ERROR: /Temp/bazel-examples/ts_project_transpiler/BUILD.bazel:25:11: in ts_project_rule rule //:tsc:
Traceback (most recent call last):
File "/private/var/tmp/_bazel_oleersoy/e1e034f754cf70db5f987ffb5af7aef0/external/aspect_rules_ts/ts/private/ts_project.bzl", line 186, column 13, in _ts_project_impl
fail(no_outs_msg + """
Error in fail: ts_project target //:tsc is configured to produce no outputs.
This might be because
- you configured it with `noEmit`
- the `srcs` are empty
- `srcs` has elements producing non-ts outputs
This is an error because Bazel does not run actions unless their outputs are needed for the requested targets to build.
ERROR: /Users/oleersoy/Temp/bazel-examples/ts_project_transpiler/BUILD.bazel:25:11: Analysis of target '//:tsc' failed
WARNING: errors encountered while analyzing target '//:tsc': it will not be built
WARNING: errors encountered while analyzing target '//:tsc_test_0__deps': it will not be built
WARNING: errors encountered while analyzing target '//:tsc_test': it will not be built
INFO: Analysis succeeded for only 43 of 46 top-level targets
INFO: Analyzed 46 targets (0 packages loaded, 0 targets configured).
INFO: Found 43 targets...
ERROR: /Users/oleersoy/Temp/bazel-examples/ts_project_transpiler/BUILD.bazel:86:15: Executing genrule //:tsc_test_1__deps failed: missing input file '//:build-tsc/big.js'
ERROR: /Users/oleersoy/Temp/bazel-examples/ts_project_transpiler/BUILD.bazel:86:15: Executing genrule //:tsc_test_2__deps failed: missing input file '//:build-tsc/big.js.map'
ERROR: /Users/oleersoy/Temp/bazel-examples/ts_project_transpiler/BUILD.bazel:86:15: Executing genrule //:tsc_test_3__deps failed: missing input file '//:build-tsc/big.d.ts'
ERROR: /Users/oleersoy/Temp/bazel-examples/ts_project_transpiler/BUILD.bazel:86:15: Executing genrule //:tsc_test_3__deps failed: 1 input file(s) do not exist
ERROR: /Users/oleersoy/Temp/bazel-examples/ts_project_transpiler/BUILD.bazel:86:15: Executing genrule //:tsc_test_1__deps failed: 1 input file(s) do not exist
ERROR: /Users/oleersoy/Temp/bazel-examples/ts_project_transpiler/BUILD.bazel:86:15: Executing genrule //:tsc_test_2__deps failed: 1 input file(s) do not exist
INFO: Elapsed time: 0.123s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
FAILED: Build did NOT complete successfully
Any ideas?
Glob only searches files in its own package, and looks only for source files (not generated files nor other targets).
However, big.ts is generated by the above gen_ts rule, so glob
won't find it.