Bazel custom build rules for TypeScript
Custom Bazel build rules to compile TypeScript.
Syntax
ts_library(
name = "externs",
srcs = ["externs.d.ts"],
)
ts_library(
name = "common",
srcs = ["common.ts"],
deps = [":externs"],
)
ts_binary(
name = "main"
srcs = ["main.ts"],
deps = [":common"],
flags = [
"--removeComments",
"--noEmitOnError",
],
)
Build example
- Install Bazel
- Add
load("/build-rules/typescript", "ts_library", "ts_binary")
to%bazel/tools/build_rules/prelude_bazel
- Run
git clone https://github.com/zmxv/bazel-custom-rules && cd bazel-custom-rules
- Run
bazel build //examples/typescript:main
- Examine the output in
bazel-bin/examples/typescript/main.js