-
Notifications
You must be signed in to change notification settings - Fork 522
/
Copy pathBUILD.bazel
98 lines (88 loc) · 2.5 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
load("@build_bazel_rules_nodejs//:index.bzl", "pkg_npm")
load("//internal/node:context.bzl", "node_context_data")
load("//packages/jasmine:index.bzl", "jasmine_node_test")
load("//packages/rollup:index.bzl", "rollup_bundle")
load("//packages/typescript:index.bzl", "ts_library")
load("//third_party/github.com/bazelbuild/bazel-skylib:rules/write_file.bzl", "write_file")
write_file(
name = "produces_files",
out = "a_dep",
content = ["a_dep content"],
)
ts_library(
name = "ts_library",
srcs = ["foo.ts"],
data = ["data.json"],
)
rollup_bundle(
name = "rollup/bundle/subdirectory",
entry_points = {
"foo.ts": "index",
},
output_dir = True,
deps = [":ts_library"],
)
pkg_npm(
name = "dependent_pkg",
srcs = ["dependent_file"],
)
# Force stamping behavior even in builds without --stamp config
# by mocking out the config data
node_context_data(
name = "force_stamp",
stamp = True,
)
pkg_npm(
name = "test_pkg",
srcs = [
"package.json",
"some_file",
"@internal_npm_package_test_vendored_external//:vendored_external_file",
],
nested_packages = [":dependent_pkg"],
node_context_data = ":force_stamp",
substitutions = {"replace_me": "replaced"},
vendor_external = [
"internal_npm_package_test_vendored_external",
],
deps = [
":bundle.min.js",
":produces_files",
":rollup/bundle/subdirectory",
":ts_library",
"@internal_npm_package_test_vendored_external//:ts_library",
],
)
pkg_npm(
name = "test_noop_pkg",
# Special case where these is a single dep that is a directory artifact
# then we assume the package is contained within that single directory
# and the pkg_npm rules does not need to copy any files
deps = [":rollup/bundle/subdirectory"],
)
pkg_npm(
name = "test_noop2_pkg",
# Special case where these is a single dep that is a directory artifact
# then we assume the package is contained within that single directory
# and the pkg_npm rules does not need to copy any files
srcs = [":rollup/bundle/subdirectory"],
)
jasmine_node_test(
name = "test",
srcs = ["pkg_npm.spec.js"],
data = [
":test_noop2_pkg",
":test_noop_pkg",
":test_pkg",
],
templated_args = [
"$(rootpath :test_pkg)",
"$(rootpath :test_noop_pkg)",
"$(rootpath :test_noop2_pkg)",
],
)
genrule(
name = "bundle",
outs = ["bundle.min.js"],
cmd = "echo -n 'bundle content' > $@",
)