Skip to content

Commit ce7416a

Browse files
committed
build: setup rules_ts for compiling TypeScript sources
This commit sets up `rules_ts`, providing the `ts_library` equivalent for the `rules_js` migration.
1 parent 6f96e19 commit ce7416a

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

.bazelrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Disable NG CLI TTY mode
22
build --action_env=NG_FORCE_TTY=false
33

4+
# Required by `rules_ts`.
5+
common --@aspect_rules_ts//ts:skipLibCheck=always
6+
common --@aspect_rules_ts//ts:default_to_tsc_transpiler
7+
48
# Make TypeScript compilation fast, by keeping a few copies of the compiler
59
# running as daemons, and cache SourceFile AST's to reduce parse time.
610
build --strategy=TypeScriptCompile=worker

BUILD.bazel

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
load("@aspect_rules_ts//ts:defs.bzl", rules_js_tsconfig = "ts_config")
2+
13
# Copyright Google Inc. All Rights Reserved.
24
#
35
# Use of this source code is governed by an MIT-style license that can be
@@ -24,6 +26,15 @@ npm_link_all_packages(
2426
name = "node_modules",
2527
)
2628

29+
rules_js_tsconfig(
30+
name = "build-tsconfig",
31+
src = "tsconfig-build.json",
32+
deps = [
33+
"tsconfig.json",
34+
"//:node_modules/@types/node",
35+
],
36+
)
37+
2738
# Files required by e2e tests
2839
copy_to_bin(
2940
name = "config-files",

WORKSPACE

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,3 +195,18 @@ npm_translate_lock(
195195
load("@npm2//:repositories.bzl", "npm_repositories")
196196

197197
npm_repositories()
198+
199+
http_archive(
200+
name = "aspect_rules_ts",
201+
sha256 = "9acd128abe77397505148eaa6895faed57839560dbf2177dd6285e51235e2724",
202+
strip_prefix = "rules_ts-3.3.1",
203+
url = "https://github.com/aspect-build/rules_ts/releases/download/v3.3.1/rules_ts-v3.3.1.tar.gz",
204+
)
205+
206+
load("@aspect_rules_ts//ts:repositories.bzl", "rules_ts_dependencies")
207+
208+
rules_ts_dependencies(
209+
# ts_version_from = "//:package.json",
210+
# TODO: Support in https://github.com/aspect-build/rules_ts/blob/main/ts/private/npm_repositories.bzl
211+
ts_version = "5.6.2",
212+
)

0 commit comments

Comments
 (0)