generated from bazel-contrib/rules-template
-
-
Notifications
You must be signed in to change notification settings - Fork 61
/
BUILD.bazel
196 lines (166 loc) · 6.08 KB
/
BUILD.bazel
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
load("@aspect_bazel_lib//lib:utils.bzl", bazel_lib_utils = "utils")
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag", "string_flag")
load("//ts/private:options.bzl", "options")
exports_files(
glob(["*.bzl"]),
visibility = ["//docs:__pkg__"],
)
_skip_lib_check_selection_required = """
######## Required Typecheck Performance Selection ########
TypeScript's type-checking exposes a flag `--skipLibCheck`:
https://www.typescriptlang.org/tsconfig#skipLibCheck
Using this flag saves substantial time during type-checking.
Rather than doing a full check of all d.ts files, TypeScript will only type-check the code you
specifically refer to in your app's source code.
We recommend this for most rules_ts users.
HOWEVER this performance improvement comes at the expense of type-system accuracy.
For example, two packages could define two copies of the same type in an inconsistent way.
If you publish a library from your repository, your incorrect types may result in errors for your users.
You must choose exactly one of the following flags:
1. To choose the faster performance put this in /.bazelrc:
# passes an argument `--skipLibCheck` to *every* spawn of tsc
# Bazel 6.4 or greater: 'common' means 'any command that supports this flag'
common --@aspect_rules_ts//ts:skipLibCheck=always
# Between Bazel 6.0 and 6.3, you need all of this, to avoid discarding the analysis cache:
build --@aspect_rules_ts//ts:skipLibCheck=always
fetch --@aspect_rules_ts//ts:skipLibCheck=always
query --@aspect_rules_ts//ts:skipLibCheck=always
# Before Bazel 6.0, only the 'build' and 'fetch' lines work.
2. To choose more correct typechecks, put this in /.bazelrc:
# honor the setting of `skipLibCheck` in the tsconfig.json file
# Bazel 6.4 or greater: 'common' means 'any command that supports this flag'
common --@aspect_rules_ts//ts:skipLibCheck=honor_tsconfig
# Between Bazel 6.0 and 6.3, you need all of this, to avoid discarding the analysis cache:
build --@aspect_rules_ts//ts:skipLibCheck=honor_tsconfig
fetch --@aspect_rules_ts//ts:skipLibCheck=honor_tsconfig
query --@aspect_rules_ts//ts:skipLibCheck=honor_tsconfig
# Before Bazel 6.0, only the 'build' and 'fetch' lines work.
##########################################################
"""
# Users can enable with --@aspect_rules_ts//ts:skipLibCheck=always
string_flag(
# Note: this name is chosen to be searchable when users look for "skipLibCheck" in their repo,
# as that's the way it appears in tsconfig.json or tsc command line.
name = "skipLibCheck",
build_setting_default = "unspecified",
values = [
"always",
"honor_tsconfig",
"unspecified",
],
visibility = ["//visibility:public"],
)
bool_flag(
name = "default_to_tsc_transpiler",
build_setting_default = False,
visibility = ["//visibility:public"],
)
bool_flag(
name = "verbose",
build_setting_default = False,
visibility = ["//visibility:public"],
)
bool_flag(
name = "supports_workers",
build_setting_default = False,
visibility = ["//visibility:public"],
)
# Note, users could use a Transition to make a subgraph of their depgraph opt-in to skipLibCheck.
config_setting(
name = "skip_lib_check.always",
flag_values = {":skipLibCheck": "always"},
)
config_setting(
name = "skip_lib_check.honor_tsconfig",
flag_values = {":skipLibCheck": "honor_tsconfig"},
)
config_setting(
name = "verbose_flag",
flag_values = {
":verbose": "true",
},
)
config_setting(
name = "supports_workers_flag",
flag_values = {
":supports_workers": "true",
},
)
config_setting(
name = "default_to_tsc_transpiler_flag",
flag_values = {
":default_to_tsc_transpiler": "true",
},
)
options(
name = "options",
default_to_tsc_transpiler = select({
":default_to_tsc_transpiler_flag": True,
"//conditions:default": False,
}),
skip_lib_check = select(
{
"@aspect_rules_ts//ts:skip_lib_check.always": True,
"@aspect_rules_ts//ts:skip_lib_check.honor_tsconfig": False,
},
no_match_error = _skip_lib_check_selection_required,
),
supports_workers = select({
":supports_workers_flag": True,
"//conditions:default": False,
}),
verbose = select({
":verbose_flag": True,
"//conditions:default": False,
}),
visibility = ["//visibility:public"],
)
bzl_library(
name = "defs",
srcs = ["defs.bzl"],
visibility = ["//visibility:public"],
deps = [
"//ts/private:build_test",
"//ts/private:options",
"//ts/private:ts_config",
"//ts/private:ts_project",
"@aspect_rules_js//js:defs",
"@bazel_skylib//lib:partial",
"@bazel_skylib//rules:build_test",
] + (["@bazel_tools//tools/build_defs/repo:cache.bzl"] if bazel_lib_utils.is_bazel_7_or_greater() else []),
)
bzl_library(
name = "repositories",
srcs = ["repositories.bzl"],
visibility = ["//visibility:public"],
deps = [
"//ts/private:npm_repositories",
"//ts/private:versions",
"@bazel_tools//tools/build_defs/repo:http.bzl",
"@bazel_tools//tools/build_defs/repo:utils.bzl",
] + (["@bazel_tools//tools/build_defs/repo:cache.bzl"] if bazel_lib_utils.is_bazel_7_or_greater() else []),
)
bzl_library(
name = "extensions",
srcs = ["extensions.bzl"],
visibility = ["//visibility:public"],
deps = [
":repositories",
"//ts/private:npm_repositories",
],
)
bzl_library(
name = "proto",
srcs = ["proto.bzl"],
visibility = ["//visibility:public"],
deps = [
"//ts/private:ts_proto_library",
"@aspect_bazel_lib//lib:copy_to_directory",
"@aspect_bazel_lib//lib:directory_path",
"@aspect_bazel_lib//lib:write_source_files",
"@aspect_rules_js//js:defs",
"@aspect_rules_js//js:libs",
"@aspect_rules_js//js:providers",
] + (["@bazel_tools//tools/build_defs/repo:cache.bzl"] if bazel_lib_utils.is_bazel_7_or_greater() else []),
)