forked from bazel-contrib/rules_nodejs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
WORKSPACE
378 lines (305 loc) · 10.3 KB
/
WORKSPACE
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
# Copyright 2017 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
workspace(
name = "build_bazel_rules_nodejs",
managed_directories = {"@npm": ["node_modules"]},
)
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("//internal/bazel_integration_test:git_repository_under_test.bzl", "git_repository_under_test")
#
# Check that build is using a minimum compatible bazel version
#
load("//internal/common:check_bazel_version.bzl", "check_bazel_version")
# 0.18.0: support for .bazelignore
# 0.23.0: required fix for pkg_tar strip_prefix
# 0.26.0: managed_directories feature added
check_bazel_version(
message = """
You no longer need to install Bazel on your machine.
rules_nodejs has a dependency on the @bazel/bazel package which supplies it.
Try running `yarn bazel` instead.
""",
minimum_bazel_version = "0.26.0",
)
#
# Nested package worksapces required to build packages & reference rules
#
load("//packages:index.bzl", "NESTED_PACKAGES")
[local_repository(
name = "npm_bazel_%s" % name,
path = "packages/%s/src" % name,
) for name in NESTED_PACKAGES]
#
# Install rules_nodejs dev dependencies
#
load("//:package.bzl", "rules_nodejs_dev_dependencies")
rules_nodejs_dev_dependencies()
#
# Setup rules_nodejs npm dependencies
#
load("//:defs.bzl", "npm_install", "yarn_install")
yarn_install(
name = "npm",
# The @npm//:node_modules_filegroup generated by manual_build_file_contents
# is used in the //packages/typescript/test/reference_types_directive:tsconfig_types
# test. For now we're still supporting node_modules as a filegroup tho this
# may change in the future. The default generated //:node_modules target is a
# node_module_library rule which provides NodeModuleInfo and NodeModuleSources
# but that rule is not yet in the public API and we have not yet dropped support
# for filegroup based node_modules target.
manual_build_file_contents = """
filegroup(
name = "node_modules_filegroup",
srcs = [
"//@types/hammerjs:hammerjs__files",
"//@types/jasmine:jasmine__files",
"//typescript:typescript__files",
],
)
""",
package_json = "//:package.json",
yarn_lock = "//:yarn.lock",
)
# Install all Bazel dependencies needed for npm packages that supply Bazel rules
load("@npm//:install_bazel_dependencies.bzl", "install_bazel_dependencies")
install_bazel_dependencies()
#
# Install npm_bazel_typescript dependencies
#
# Uncomment for local development
# local_repository(
# name = "build_bazel_rules_typescript",
# path = "../../../rules_typescript",
# )
# We use git_repository since Renovate knows how to update it.
# With http_archive it only sees releases/download/*.tar.gz urls
git_repository(
name = "build_bazel_rules_typescript",
commit = "a491eba48358bdb2f1a7b78ece965be1fb918bb8",
remote = "http://github.com/bazelbuild/rules_typescript.git",
)
# We have a source dependency on build_bazel_rules_typescript
# so we must repeat its transitive toolchain deps
load("@build_bazel_rules_typescript//:package.bzl", "rules_typescript_dev_dependencies")
rules_typescript_dev_dependencies()
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
gazelle_dependencies()
go_rules_dependencies()
go_register_toolchains()
load("@build_bazel_rules_typescript//internal:ts_repositories.bzl", "ts_setup_dev_workspace")
ts_setup_dev_workspace()
load("@npm_bazel_typescript//internal:ts_repositories.bzl", "ts_setup_workspace")
ts_setup_workspace()
#
# Install npm_bazel_karma dependencies
#
load("@npm_bazel_karma//:package.bzl", "rules_karma_dependencies")
rules_karma_dependencies()
# Setup the rules_webtesting toolchain
load("@io_bazel_rules_webtesting//web:repositories.bzl", "web_test_repositories")
web_test_repositories()
# Temporary work-around for https://github.com/angular/angular/issues/28681
# TODO(gregmagolan): go back to @io_bazel_rules_webtesting browser_repositories
load("@npm_bazel_karma//:browser_repositories.bzl", "browser_repositories")
browser_repositories()
#
# Dependencies to run skydoc & generating documentation
#
load("@io_bazel_rules_sass//sass:sass_repositories.bzl", "sass_repositories")
sass_repositories()
load("@io_bazel_skydoc//skylark:skylark.bzl", "skydoc_repositories")
skydoc_repositories()
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
protobuf_deps()
# Needed for starlark unit testing
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
bazel_skylib_workspace()
#
# Setup local respositories & install npm dependencies for tests
#
local_repository(
name = "internal_npm_package_test_vendored_external",
path = "internal/npm_package/test/vendored_external",
)
yarn_install(
name = "fine_grained_deps_yarn",
included_files = [
"",
".js",
".d.ts",
".json",
".proto",
],
package_json = "//internal/e2e/fine_grained_deps:yarn/package.json",
symlink_node_modules = False,
yarn_lock = "//internal/e2e/fine_grained_deps:yarn/yarn.lock",
)
npm_install(
name = "fine_grained_deps_npm",
included_files = [
"",
".js",
".d.ts",
".json",
".proto",
],
package_json = "//internal/e2e/fine_grained_deps:npm/package.json",
package_lock_json = "//internal/e2e/fine_grained_deps:npm/package-lock.json",
symlink_node_modules = False,
)
yarn_install(
name = "fine_grained_no_bin",
package_json = "//internal/e2e/fine_grained_no_bin:package.json",
symlink_node_modules = False,
yarn_lock = "//internal/e2e/fine_grained_no_bin:yarn.lock",
)
yarn_install(
name = "npm_install_test",
# exercise the dynamic_deps feature, even though it doesn't make sense for a real jasmine binary to depend on zone.js
# This will just inject an extra data[] dependency into the jasmine_bin generated target.
dynamic_deps = {"jasmine": "zone.js"},
manual_build_file_contents = """
filegroup(
name = "test_files",
srcs = [
"//:BUILD.bazel",
"//:install_bazel_dependencies.bzl",
"//:manual_build_file_contents",
"//:WORKSPACE",
"//@angular/core:BUILD.bazel",
"//@gregmagolan:BUILD.bazel",
"//@gregmagolan/test-a/bin:BUILD.bazel",
"//@gregmagolan/test-a:BUILD.bazel",
"//@gregmagolan/test-b/bin:BUILD.bazel",
"//@gregmagolan/test-b:BUILD.bazel",
"//ajv:BUILD.bazel",
"//jasmine/bin:BUILD.bazel",
"//jasmine:BUILD.bazel",
"//rxjs:BUILD.bazel",
"//unidiff/bin:BUILD.bazel",
"//unidiff:BUILD.bazel",
"//zone.js:BUILD.bazel",
],
)""",
package_json = "//internal/npm_install/test:package.json",
symlink_node_modules = False,
yarn_lock = "//internal/npm_install/test:yarn.lock",
)
#
# RBE configuration
#
load("@bazel_toolchains//rules:rbe_repo.bzl", "rbe_autoconfig")
# Creates toolchain configuration for remote execution with BuildKite CI
# for rbe_ubuntu1604
rbe_autoconfig(
name = "buildkite_config",
)
rbe_autoconfig(
name = "rbe_default",
)
load("@build_bazel_integration_testing//tools:repositories.bzl", "bazel_binaries")
# Depend on the Bazel binaries
bazel_binaries(versions = ["0.28.1"])
#
# Support creating Docker images for our node apps #
# Not used but needed for @e2e_angular_bazel_example//:bazel_integration_test_files target
#
http_archive(
name = "io_bazel_rules_docker",
sha256 = "aed1c249d4ec8f703edddf35cbe9dfaca0b5f5ea6e4cd9e83e99f3b0d1136c3d",
strip_prefix = "rules_docker-0.7.0",
urls = ["https://github.com/bazelbuild/rules_docker/archive/v0.7.0.tar.gz"],
)
load("@io_bazel_rules_docker//nodejs:image.bzl", nodejs_image_repos = "repositories")
nodejs_image_repos()
#
# Kubernetes setup, for deployment to Google Cloud
# Not used but needed for @e2e_angular_bazel_example//:bazel_integration_test_files target
#
git_repository(
name = "io_bazel_rules_k8s",
commit = "36ae5b534cc51ab0815c9bc723760469a9f7175c",
remote = "https://github.com/bazelbuild/rules_k8s.git",
shallow_since = "1545317854 -0500",
)
load("@io_bazel_rules_k8s//k8s:k8s.bzl", "k8s_defaults", "k8s_repositories")
k8s_repositories()
k8s_defaults(
# This creates a rule called "k8s_deploy" that we can call later
name = "k8s_deploy",
# This is the name of the cluster as it appears in:
# kubectl config view --minify -o=jsonpath='{.contexts[0].context.cluster}'
cluster = "_".join([
"gke",
"internal-200822",
"us-west1-a",
"angular-bazel-example",
]),
kind = "deployment",
)
#
# Setup bazel_integration_test repositories
#
[local_repository(
name = "e2e_%s" % name,
path = "e2e/%s" % name,
) for name in [
"bazel_managed_deps",
"fine_grained_symlinks",
"jasmine",
"karma",
"karma_stack_trace",
"karma_typescript",
"less",
"node_loader_no_preserve_symlinks",
"node_loader_preserve_symlinks",
"packages",
"stylus",
"symlinked_node_modules_npm",
"symlinked_node_modules_yarn",
"ts_auto_deps",
"ts_devserver",
"typescript",
"webpack",
]]
load("@e2e_packages//:setup_workspace.bzl", "e2e_packages_setup_workspace")
e2e_packages_setup_workspace()
git_repository_under_test(
name = "e2e_angular_bazel_example",
branch = "add-buildkite-filter-flags",
remote = "http://github.com/gregmagolan/angular-bazel-example.git",
)
# Mock npm_angular_bazel for @e2e_angular_bazel_example//:bazel_integration_test_files target
local_repository(
name = "npm_angular_bazel",
path = "tools/mock_npm_angular_bazel",
)
[local_repository(
name = "examples_%s" % name,
path = "examples/%s" % name,
) for name in [
"app",
"nestjs",
"parcel",
"program",
"protocol_buffers",
"user_managed_deps",
"vendored_node",
"vendored_node_and_yarn",
"web_testing",
"webapp",
"worker",
]]