forked from aspect-build/rules_ts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBUILD.typescript
95 lines (82 loc) · 2.31 KB
/
BUILD.typescript
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
"BUILD file inserted into @npm_typescript repository"
load("@aspect_rules_js//js:defs.bzl", "js_binary")
load("@aspect_rules_js//npm/private:npm_package_internal.bzl", "npm_package_internal")
load("@aspect_rules_js//npm:defs.bzl", "npm_link_package")
load("@aspect_bazel_lib//lib:directory_path.bzl", "directory_path")
load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
load("@bazel_skylib//rules:write_file.bzl", "write_file")
load("@bazel_skylib//rules:common_settings.bzl", "bool_setting")
bool_setting(
name = "is_typescript_5_or_greater_flag",
build_setting_default = is_ts_5,
visibility = ["//visibility:public"],
)
config_setting(
name = "is_typescript_5_or_greater",
flag_values = {
":is_typescript_5_or_greater_flag": "true",
},
visibility = ["//visibility:public"],
)
npm_package_internal(
name = "npm_typescript",
src = "package",
package = "typescript",
version = "ts_version",
)
npm_link_package(
name = "node_modules/typescript",
src = "npm_typescript",
visibility = ["//visibility:public"],
)
# tsc
directory_path(
name = "tsc_entrypoint",
directory = ":node_modules/typescript/dir",
path = "bin/tsc",
visibility = ["//visibility:public"],
)
js_binary(
name = "tsc",
data = [":node_modules/typescript"],
entry_point = ":tsc_entrypoint",
visibility = ["//visibility:public"],
)
# validator
copy_file(
name = "copy_validator",
src = "@aspect_rules_ts//ts/private:ts_project_options_validator.js",
out = "ts_project_options_validator.js",
)
js_binary(
name = "validator",
data = [":node_modules/typescript"],
entry_point = "copy_validator",
visibility = ["//visibility:public"],
)
# tsc worker
copy_file(
name = "copy_worker_js",
src = "@aspect_rules_js//js/private/worker:worker.js",
out = "worker.js",
)
copy_file(
name = "copy_ts_project_worker",
src = "@aspect_rules_ts//ts/private:ts_project_worker.js",
out = "ts_project_worker.js",
)
write_file(
name = "package_json",
out = "package.json",
content = ["{\"type\": \"commonjs\"}"],
)
js_binary(
name = "tsc_worker",
data = [
":copy_worker_js",
":node_modules/typescript",
":package_json",
],
entry_point = "copy_ts_project_worker",
visibility = ["//visibility:public"],
)