-
-
Notifications
You must be signed in to change notification settings - Fork 107
/
BUILD.bazel
123 lines (107 loc) · 3.57 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
load("@acorn__8.4.0__links//:defs.bzl", npm_link_acorn = "npm_link_imported_package")
load("@aspect_bazel_lib//lib:diff_test.bzl", "diff_test")
load("@bazel_gazelle//:def.bzl", "gazelle", "gazelle_binary")
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@buildifier_prebuilt//:rules.bzl", "buildifier")
load("@npm//:defs.bzl", "npm_link_all_packages", "npm_link_targets")
load("@pnpm__links//:defs.bzl", npm_link_pnpm = "npm_link_imported_package")
load("//js:defs.bzl", "js_library")
load("//npm:defs.bzl", "npm_link_package")
# Link all packages from the /WORKSPACE npm_translate_lock(name = "npm") and also packages from
# manual /WORKSPACE npm_import rules to bazel-bin/node_modules as well as the package store
# bazel-bin/node_modules/.aspect_rules_js since /pnpm-lock.yaml is the root of the pnpm workspace
npm_link_all_packages(
name = "node_modules",
imported_links = [
npm_link_acorn,
npm_link_pnpm,
],
)
# Ensure that jsonplus-plus is in the output tree for the @kubernetes/client-node sandboxed lifecycle
# hook test case
build_test(
name = "node_modules_build_test",
targets = ["//:node_modules"],
)
# buildifier: disable=duplicated-name
NODE_MODULES = npm_link_targets(
name = "node_modules",
package = package_name(),
) + [
"//:node_modules/acorn",
"//:node_modules/pnpm",
]
js_library(
name = "npm_link_targets_node_modules",
srcs = NODE_MODULES,
)
build_test(
name = "npm_link_targets_node_modules_build_test",
targets = ["//:npm_link_targets_node_modules"],
)
genquery(
name = "query_node_modules",
expression = "deps(//:node_modules) - //:node_modules",
scope = ["//:node_modules"],
)
genquery(
name = "query_npm_link_targets_node_modules",
expression = "deps(//:npm_link_targets_node_modules) - //:npm_link_targets_node_modules",
scope = ["//:npm_link_targets_node_modules"],
)
# Verifies that the targets list in //:npm_link_targets_node_modules is the same as //:node_modules
diff_test(
name = "npm_link_targets_test",
file1 = "query_node_modules",
file2 = "query_npm_link_targets_node_modules",
)
# Example of manually linking a first-party dependency. Its transitive npm dependencies
# are picked up automatically via 'npm_package_store_infos' in the js_library targets that
# the `npm_package` target depends on.
npm_link_package(
name = "node_modules/@mycorp/pkg-b",
src = "//examples/npm_package/packages/pkg_b:pkg",
)
# Manually linked pkg-c with additional use cases.
npm_link_package(
name = "node_modules/@mycorp/pkg-c1",
src = "//examples/npm_package/packages/pkg_c:pkg_c1",
)
npm_link_package(
name = "node_modules/@mycorp/pkg-c2",
src = "//examples/npm_package/packages/pkg_c:pkg_c2",
)
gazelle_binary(
name = "gazelle_bin",
languages = ["@bazel_skylib_gazelle_plugin//bzl"],
)
gazelle(
name = "gazelle",
gazelle = "gazelle_bin",
)
buildifier(
name = "buildifier",
exclude_patterns = [
"./.git/*",
"**/snapshots/**",
],
lint_mode = "fix",
lint_warnings = ["-out-of-order-load"], # TODO: enable out-of-order-load
mode = "fix",
tags = ["manual"], # tag as manual so windows ci does not build it by default
)
buildifier(
name = "buildifier.check",
exclude_patterns = [
"./.git/*",
"**/snapshots/**",
],
lint_mode = "warn",
lint_warnings = ["-out-of-order-load"], # TODO: enable out-of-order-load
mode = "diff",
tags = ["manual"], # tag as manual so windows ci does not build it by default
)
alias(
name = "format",
actual = "//tools:format",
)