-
Notifications
You must be signed in to change notification settings - Fork 373
/
Copy pathts_library.bzl
41 lines (39 loc) · 1.18 KB
/
ts_library.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
load("@aspect_rules_ts//ts:defs.bzl", native_ts_library = "ts_project")
load("@npm//:mocha/package_json.bzl", mocha = "bin")
def ts_library(tsconfig = None, **kwargs):
native_ts_library(
tsconfig = tsconfig if tsconfig else "//:tsconfig",
declaration = True,
source_map = True,
transpiler = "tsc",
**kwargs
)
def ts_mocha_test_suite(srcs, tsconfig = None, **kwargs):
for src in srcs:
if not src.endswith(".spec.ts"):
break
test_name = src[:-3]
lib_name = test_name + "_lib"
ts_library(
name = lib_name,
srcs = [src],
tsconfig = tsconfig,
testonly = True,
**kwargs
)
mocha.mocha_test(
name = test_name,
data = [
":" + lib_name,
"//:package_json",
# "//:node_modules/source-map-support",
],
node_options = [
"--experimental-specifier-resolution=node",
# "-r",
# "source-map-support/register",
],
args = [
"**/" + test_name + ".js",
],
)