rules_tsickle provides a closure_ts_compile rule that transforms .ts files
into closure-annotated .js files. It contains a vendored copy of
https://github.com/angular/tsickle (which was archived in May 2025).
The primary reason rules_tsickle was created was to perform .ts to .js
translation of https://github.com/google/safevalues for
https://github.com/google/closure-templates/tree/master/javascript. Several
of the soyutils files in that repo have closure dependencies like:
goog.require('google3.third_party.javascript.safevalues.index');No open-source copy of the translated .js files could be located, so
rules_tsickle was created to perform that translation.
To use rules_tsickle in your own bazel workspace (lookup most recent version):
bazel_dep("rules_tsickle", version = "0.0.0")Then, in a package containing .ts and/or .d.ts files:
load("//rules:defs.bzl", "closure_ts_compile")
closure_ts_compile(
name = "index",
srcs = ["index.ts"],
)bazel build :index will:
- download npm deps and prepare the
js_binarytsickle runner (//tools/tsicklecompiler). - run the tool, which roughly works as follows:
- prepare an internal/minimal
tsconfig.jsonconfiguration. - runs
tscover the inputs to generate ats.Program - runs tsickle over the
ts.Programto AST-rewrite/transform it. - emits the transformed
.jsfiles.
- prepare an internal/minimal
- output files:
- each
{basename}.tswill produce an equivalent{basename}.jsfile - if any
.d.tsfiles are present, a single{name}-externs.jsfile will be produced.
- each
closure_ts_compile can take deps on other closure_ts_compile rules. The
source .ts files will be made available to tsc. Only direct .ts files in
the primary rule will emitted.
The rules_tsickle initial version is 1.0.0 not because of a long history of
development, but because it is anticipated this repo will not see a large amount
of future development.