-
Notifications
You must be signed in to change notification settings - Fork 0
/
defs.bzl
48 lines (41 loc) · 1.13 KB
/
defs.bzl
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
load("@build_bazel_rules_nodejs//:index.bzl", _js = "js_library")
load("@npm//@bazel/typescript:index.bzl", _ts_project = "ts_project")
load("@aspect_rules_swc//swc:swc.bzl", "swc_rule")
_DEPS = [
"@npm//@types/react",
"@npm//tslib",
]
def swc(name, **kwargs):
kwargs["swcrc"] = "//:.swcrc"
swc_rule(name = name, **kwargs)
def js_library(name, srcs, **kwargs):
_js(name, srcs, **kwargs)
def ts_project(name, srcs, **kwargs):
tsconfig = {
"compilerOptions": {
"allowJs": True,
"declaration": True,
"strict": True,
"noImplicitAny": True,
},
}
deps = kwargs.pop("deps", [])
deps += _DEPS
# This is needed to import CSS
srcs.append("//:Global.d.ts")
data = kwargs.pop("data", [])
_ts_project(
name = name,
transpiler = swc,
srcs = srcs,
deps = deps,
data = data,
allow_js = True,
declaration = True,
declaration_map = True,
preserve_jsx = True,
link_workspace_root = True,
extends = "//:tsconfig.json",
tsconfig = tsconfig,
**kwargs
)