Custom Bazel build rules to compile TypeScript
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
build-rules
examples/typescript
.gitignore
README.md
WORKSPACE

README.md

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

  1. Install Bazel
  2. Add load("/build-rules/typescript", "ts_library", "ts_binary") to %bazel/tools/build_rules/prelude_bazel
  3. Run git clone https://github.com/zmxv/bazel-custom-rules && cd bazel-custom-rules
  4. Run bazel build //examples/typescript:main
  5. Examine the output in bazel-bin/examples/typescript/main.js