forked from angular/angular
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdefaults2.bzl
More file actions
121 lines (99 loc) · 4.48 KB
/
Copy pathdefaults2.bzl
File metadata and controls
121 lines (99 loc) · 4.48 KB
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
load("@aspect_rules_jasmine//jasmine:defs.bzl", _jasmine_test = "jasmine_test")
load("@aspect_rules_js//npm:defs.bzl", _npm_package = "npm_package")
load("@aspect_rules_ts//ts:defs.bzl", _ts_config = "ts_config")
load("@rules_angular//src/ng_package:index.bzl", _ng_package = "ng_package")
load("@rules_angular//src/ng_project:index.bzl", _ng_project = "ng_project")
load("//tools/bazel:module_name.bzl", "compute_module_name")
load("//tools/bazel:ts_project_interop.bzl", _ts_project = "ts_project")
npm_package = _npm_package
ts_config = _ts_config
def _determine_tsconfig(testonly):
if native.package_name().startswith("packages/compiler-cli/src/ngtsc"):
return "//packages/compiler-cli:tsconfig_test" if testonly else "//packages/compiler-cli:tsconfig_build"
if native.package_name().startswith("packages/service-worker"):
return "//packages:tsconfig_test" if testonly else "//packages/service-worker:tsconfig_build"
if native.package_name().startswith("packages/core/schematics"):
return "//packages/core/schematics:tsconfig_test" if testonly else "//packages/core/schematics:tsconfig_build"
if native.package_name().startswith("packages/core"):
return "//packages/core:tsconfig_test" if testonly else "//packages/core:tsconfig_build"
if native.package_name().startswith("packages/benchpress"):
return "//packages:tsconfig_test" if testonly else "//packages/benchpress:tsconfig_build"
if native.package_name().startswith("packages/language-service"):
return "//packages:tsconfig_test" if testonly else "//packages/language-service:tsconfig_build"
if native.package_name().startswith("packages/localize/tools"):
return "//packages:tsconfig_test" if testonly else "//packages/localize/tools:tsconfig_build"
if native.package_name().startswith("packages/common/locales/generate-locales-tool"):
return "//packages:tsconfig_test" if testonly else "//packages/common/locales/generate-locales-tool:tsconfig_build"
if native.package_name().startswith("packages/examples"):
return "//packages/examples:tsconfig_test" if testonly else "//packages/examples:tsconfig_build"
if native.package_name().startswith("packages"):
return "//packages:tsconfig_test" if testonly else "//packages:tsconfig_build"
if native.package_name().startswith("tools"):
return "//tools:tsconfig_test" if testonly else "//tools:tsconfig_build"
fail("Failing... a tsconfig value must be provided.")
def ts_project(
name,
source_map = True,
testonly = False,
tsconfig = None,
**kwargs):
module_name = kwargs.pop("module_name", compute_module_name(testonly))
if tsconfig == None:
tsconfig = _determine_tsconfig(testonly)
_ts_project(
name,
source_map = source_map,
module_name = module_name,
testonly = testonly,
tsconfig = tsconfig,
**kwargs
)
def ng_project(
name,
source_map = True,
testonly = False,
tsconfig = None,
**kwargs):
module_name = kwargs.pop("module_name", compute_module_name(testonly))
if tsconfig == None:
tsconfig = _determine_tsconfig(testonly)
_ts_project(
name,
source_map = source_map,
module_name = module_name,
rule_impl = _ng_project,
testonly = testonly,
tsconfig = tsconfig,
**kwargs
)
def jasmine_test(name, data = [], args = [], **kwargs):
# Create relative path to root, from current package dir. Necessary as
# we change the `chdir` below to the package directory.
relative_to_root = "/".join([".."] * len(native.package_name().split("/")))
_jasmine_test(
name = name,
node_modules = "//:node_modules",
chdir = native.package_name(),
fixed_args = [
"--require=%s/node_modules/source-map-support/register.js" % relative_to_root,
"**/*spec.js",
"**/*spec.mjs",
"**/*spec.cjs",
] + args,
data = data + [
"//:node_modules/source-map-support",
],
**kwargs
)
def ng_package(deps = [], **kwargs):
_ng_package(
deps = deps,
rollup_runtime_deps = [
"//:node_modules/@rollup/plugin-commonjs",
"//:node_modules/@rollup/plugin-node-resolve",
"//:node_modules/magic-string",
"//:node_modules/rollup-plugin-dts",
"//:node_modules/rollup-plugin-sourcemaps2",
],
**kwargs
)