Skip to content

Commit 762e057

Browse files
devversionAndrewKushnir
authored andcommitted
build: update to rules_nodejs v4.0.0-beta.0 (angular#42760)
Updates the Bazel NodeJS rules to v4.0.0-beta.0. This is necessary so that the Angular components repo can update, and it's generally good to stay as up-to-date as possible with the Bazel rules as it's easy to fall behind, and updating early allows us to discover issues affecting our tooling earlier (where they are easier to address due to e.g. potential breaking change policy). PR Close angular#42760
1 parent 9da68a7 commit 762e057

File tree

38 files changed

+201
-141
lines changed

38 files changed

+201
-141
lines changed

WORKSPACE

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
88
# Fetch rules_nodejs so we can install our npm dependencies
99
http_archive(
1010
name = "build_bazel_rules_nodejs",
11-
sha256 = "8f5f192ba02319254aaf2cdcca00ec12eaafeb979a80a1e946773c520ae0a2c9",
12-
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/3.7.0/rules_nodejs-3.7.0.tar.gz"],
11+
sha256 = "5c40083120eadec50a3497084f99bc75a85400ea727e82e0b2f422720573130f",
12+
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/4.0.0-beta.0/rules_nodejs-4.0.0-beta.0.tar.gz"],
1313
)
1414

1515
# Check the rules_nodejs version and download npm dependencies

dev-infra/BUILD.bazel

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# BEGIN-INTERNAL
22
load("@build_bazel_rules_nodejs//:index.bzl", "pkg_npm")
3-
load("@npm//@bazel/typescript:index.bzl", "ts_library")
4-
load("//dev-infra:index.bzl", "ng_dev_rolled_up_generated_file")
3+
load("//dev-infra:defaults.bzl", "ng_dev_rolled_up_generated_file", "ts_library")
54
# END-INTERNAL
65

76
exports_files(["tsconfig.json"])
@@ -12,7 +11,6 @@ ts_library(
1211
srcs = [
1312
"cli.ts",
1413
],
15-
module_name = "@angular/dev-infra-private",
1614
deps = [
1715
"//dev-infra/caretaker",
1816
"//dev-infra/commit-message",
@@ -47,6 +45,7 @@ genrule(
4745
pkg_npm(
4846
name = "npm_package",
4947
srcs = [
48+
# Main bazel entry-point for the shared `dev-infra` package.
5049
"index.bzl",
5150
"BUILD.bazel",
5251
# Some tools within `dev-infra` which are shipped as Bazel rules might
@@ -60,12 +59,13 @@ pkg_npm(
6059
# substitutions to replace these in the published version of dev-infra.
6160
"//dev-infra/": "@npm//@angular/dev-infra-private/",
6261
"//dev-infra:": "@npm//@angular/dev-infra-private:",
62+
63+
# Substitutions needed for `//dev-infra/benchmark`:
6364
"//packages/benchpress": "@npm//@angular/benchpress",
6465
"//packages/bazel": "@npm//@angular/bazel",
6566
"//packages/zone.js/bundles:zone.umd.js": "@npm//zone.js",
6667
"//packages/core": "@npm//@angular/core",
6768
"//packages/platform-browser": "@npm//@angular/platform-browser",
68-
6969
# This substitution is particularly verbose because we need to make sure
7070
# that only things available via Angular Bazel are imported from
7171
# tools/defaults.bzl.

dev-infra/benchmark/driver-utilities/BUILD.bazel

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
package(default_visibility = ["//visibility:public"])
1+
load("//dev-infra:defaults.bzl", "ts_library")
22

3-
load("@npm//@bazel/typescript:index.bzl", "ts_library")
3+
package(default_visibility = ["//visibility:public"])
44

55
ts_library(
66
name = "driver-utilities",
77
srcs = glob(["*.ts"]),
8-
module_name = "@angular/dev-infra-private/benchmark/driver-utilities",
98
tsconfig = "//dev-infra/benchmark/component_benchmark:tsconfig-e2e.json",
109
deps = [
1110
"//packages/benchpress",

dev-infra/caretaker/BUILD.bazel

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
load("@npm//@bazel/typescript:index.bzl", "ts_library")
2-
load("//tools:defaults.bzl", "jasmine_node_test")
1+
load("//dev-infra:defaults.bzl", "jasmine_node_test", "ts_library")
32

43
ts_library(
54
name = "caretaker",
65
srcs = glob(
76
["**/*.ts"],
87
exclude = ["**/*.spec.ts"],
98
),
10-
module_name = "@angular/dev-infra-private/caretaker",
119
visibility = ["//dev-infra:__subpackages__"],
1210
deps = [
1311
"//dev-infra/release/versioning",
@@ -41,7 +39,6 @@ ts_library(
4139

4240
jasmine_node_test(
4341
name = "test",
44-
bootstrap = ["//tools/testing:node_no_angular_es5"],
4542
deps = [
4643
":test_lib",
4744
],

dev-infra/commit-message/BUILD.bazel

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
load("//tools:defaults.bzl", "jasmine_node_test")
2-
load("@npm//@bazel/typescript:index.bzl", "ts_library")
1+
load("//dev-infra:defaults.bzl", "jasmine_node_test", "ts_library")
32

43
ts_library(
54
name = "commit-message",
65
srcs = glob(
76
["**/*.ts"],
87
exclude = ["**/*.spec.ts"],
98
),
10-
module_name = "@angular/dev-infra-private/commit-message",
119
visibility = ["//dev-infra:__subpackages__"],
1210
deps = [
1311
"//dev-infra/utils",
@@ -41,7 +39,6 @@ ts_library(
4139

4240
jasmine_node_test(
4341
name = "test",
44-
bootstrap = ["//tools/testing:node_no_angular_es5"],
4542
deps = [
4643
":test_lib",
4744
],

dev-infra/defaults.bzl

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
"""
2+
Defaults for the `//dev-infra` Bazel package. These are different than
3+
the defaults in `//tools:defaults.bzl` which are specific to the package
4+
structure as seen within `/packages/`.
5+
"""
6+
7+
load("@build_bazel_rules_nodejs//:index.bzl", "generated_file_test")
8+
load("@npm//@bazel/jasmine:index.bzl", _jasmine_node_test = "jasmine_node_test")
9+
load("@npm//@bazel/typescript:index.bzl", _ts_library = "ts_library")
10+
load("@npm//@bazel/rollup:index.bzl", "rollup_bundle")
11+
12+
NPM_PACKAGE_NAME = "@angular/dev-infra-private"
13+
14+
def _compute_module_name():
15+
current_pkg = native.package_name()
16+
17+
if current_pkg == "dev-infra":
18+
return NPM_PACKAGE_NAME
19+
20+
# For deep targets within `//dev-infra` construct the module name in a way that matches
21+
# the structure within the NPM package (i.e. simply appending the actual package path)
22+
return "%s/%s" % (NPM_PACKAGE_NAME, current_pkg[len("dev-infra/"):])
23+
24+
def ts_library(name, **kwargs):
25+
_ts_library(
26+
name = name,
27+
# If no `module_name` is set, compute a module name based on the current Bazel
28+
# package. The module names should match the NPM package structure so that the NPM
29+
# package can be used properly. Note that we disallow any custom `module_name` for
30+
# `//dev-infra` as this usually signifies a mistake we want to raise awareness for.
31+
module_name = _compute_module_name(),
32+
# We use the module name as package name, so that the target can be resolved within
33+
# NodeJS executions, by activating the Bazel NodeJS linker.
34+
# See: https://github.com/bazelbuild/rules_nodejs/pull/2799.
35+
package_name = _compute_module_name(),
36+
**kwargs
37+
)
38+
39+
def jasmine_node_test(**kwargs):
40+
_jasmine_node_test(**kwargs)
41+
42+
# This file continues to serve as indicator for `rules_nodejs` and instructs it to preserve the
43+
# content output in the NPM install workspace. This allows consumers to use rules and targets from
44+
# within Bazel. e.g. by using `@npm//@angular/dev-infra-private/<..>`.
45+
# See: https://github.com/bazelbuild/rules_nodejs/commit/4f508b1a0be1f5444e9c13b0439e649449792fef.
46+
47+
def ng_dev_rolled_up_generated_file(name, entry_point, deps = [], rollup_args = []):
48+
"""Rollup and generated file test macro.
49+
50+
This provides a single macro to create a rollup bundled script and a generated file
51+
test for the created script to ensure it stays up to date in the repository.
52+
"""
53+
rollup_bundle(
54+
name = "%s_bundle" % name,
55+
args = rollup_args,
56+
entry_point = entry_point,
57+
format = "cjs",
58+
silent = True,
59+
sourcemap = "false",
60+
deps = deps,
61+
)
62+
63+
generated_file_test(
64+
name = name,
65+
src = "%s.js" % name,
66+
generated = "%s_bundle" % name,
67+
)

dev-infra/format/BUILD.bazel

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
load("@npm//@bazel/typescript:index.bzl", "ts_library")
1+
load("//dev-infra:defaults.bzl", "ts_library")
22

33
ts_library(
44
name = "format",
55
srcs = glob([
66
"**/*.ts",
77
]),
8-
module_name = "@angular/dev-infra-private/format",
98
visibility = ["//dev-infra:__subpackages__"],
109
deps = [
1110
"//dev-infra/utils",

dev-infra/index.bzl

+3-28
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,7 @@
33
# Use of this source code is governed by an MIT-style license that can be
44
# found in the LICENSE file at https://angular.io/license
55

6-
load("@build_bazel_rules_nodejs//:index.bzl", "generated_file_test")
7-
load("@npm//@bazel/rollup:index.bzl", "rollup_bundle")
8-
9-
# This file continues to serve as indicator for `rules_nodejs` and instructs it preserve the
10-
# content output in the NPM install workspace. This allows consumers to use rules and targets from
11-
# within Bazel. e.g. by using `@npm//@angular/dev-infra-private/<..>`.
6+
# File is currently empty but serves as indicator for `rules_nodejs` and instructs it to
7+
# preserve the content output in the NPM install workspace. This allows consumers to use
8+
# rules and targets from within Bazel. e.g. by using `@npm//@angular/dev-infra-private/<..>`.
129
# See: https://github.com/bazelbuild/rules_nodejs/commit/4f508b1a0be1f5444e9c13b0439e649449792fef.
13-
14-
def ng_dev_rolled_up_generated_file(name, entry_point, deps = [], rollup_args = []):
15-
"""Rollup and generated file test macro.
16-
17-
This provides a single macro to create a rollup bundled script and a generated file test for the
18-
created script to ensure it stays up to date in the repository.
19-
"""
20-
rollup_bundle(
21-
name = "%s_bundle" % name,
22-
args = rollup_args,
23-
entry_point = entry_point,
24-
format = "cjs",
25-
silent = True,
26-
sourcemap = "false",
27-
deps = deps,
28-
)
29-
30-
generated_file_test(
31-
name = name,
32-
src = "%s.js" % name,
33-
generated = "%s_bundle" % name,
34-
)

dev-infra/misc/BUILD.bazel

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
load("@npm//@bazel/typescript:index.bzl", "ts_library")
1+
load("//dev-infra:defaults.bzl", "ts_library")
22

33
ts_library(
44
name = "misc",
55
srcs = glob(["**/*.ts"]),
6-
module_name = "@angular/dev-infra-private/misc/",
76
visibility = ["//dev-infra:__subpackages__"],
87
deps = [
98
"//dev-infra/release/build",

dev-infra/ngbot/BUILD.bazel

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
load("@npm//@bazel/typescript:index.bzl", "ts_library")
1+
load("//dev-infra:defaults.bzl", "ts_library")
22

33
ts_library(
44
name = "ngbot",
55
srcs = [
66
"cli.ts",
77
"verify.ts",
88
],
9-
module_name = "@angular/dev-infra-private/ngbot",
109
visibility = ["//dev-infra:__subpackages__"],
1110
deps = [
1211
"//dev-infra/utils",

dev-infra/pr/BUILD.bazel

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
load("@npm//@bazel/typescript:index.bzl", "ts_library")
1+
load("//dev-infra:defaults.bzl", "ts_library")
22

33
ts_library(
44
name = "pr",
55
srcs = ["cli.ts"],
6-
module_name = "@angular/dev-infra-private/pr",
76
visibility = ["//dev-infra:__subpackages__"],
87
deps = [
98
"//dev-infra/pr/check-target-branches",

dev-infra/pr/check-target-branches/BUILD.bazel

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
load("@npm//@bazel/typescript:index.bzl", "ts_library")
1+
load("//dev-infra:defaults.bzl", "ts_library")
22

33
ts_library(
44
name = "check-target-branches",
55
srcs = glob(["*.ts"]),
6-
module_name = "@angular/dev-infra-private/pr/check-target-branches",
76
visibility = ["//dev-infra:__subpackages__"],
87
deps = [
98
"//dev-infra/pr/merge",

dev-infra/pr/checkout/BUILD.bazel

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
load("@npm//@bazel/typescript:index.bzl", "ts_library")
1+
load("//dev-infra:defaults.bzl", "ts_library")
22

33
ts_library(
44
name = "checkout",
55
srcs = glob(["*.ts"]),
6-
module_name = "@angular/dev-infra-private/pr/checkout",
76
visibility = ["//dev-infra:__subpackages__"],
87
deps = [
98
"//dev-infra/pr/common",

dev-infra/pr/common/BUILD.bazel

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
load("@npm//@bazel/typescript:index.bzl", "ts_library")
1+
load("//dev-infra:defaults.bzl", "ts_library")
22

33
ts_library(
44
name = "common",
55
srcs = glob(["*.ts"]),
6-
module_name = "@angular/dev-infra-private/pr/common",
76
visibility = ["//dev-infra:__subpackages__"],
87
deps = [
98
"//dev-infra/utils",

dev-infra/pr/discover-new-conflicts/BUILD.bazel

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
load("@npm//@bazel/typescript:index.bzl", "ts_library")
1+
load("//dev-infra:defaults.bzl", "ts_library")
22

33
ts_library(
44
name = "discover-new-conflicts",
55
srcs = [
66
"cli.ts",
77
"index.ts",
88
],
9-
module_name = "@angular/dev-infra-private/pr/discover-new-conflicts",
109
visibility = ["//dev-infra:__subpackages__"],
1110
deps = [
1211
"//dev-infra/utils",

dev-infra/pr/merge/BUILD.bazel

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
load("@npm//@bazel/typescript:index.bzl", "ts_library")
2-
load("//tools:defaults.bzl", "jasmine_node_test")
1+
load("//dev-infra:defaults.bzl", "jasmine_node_test", "ts_library")
32

43
ts_library(
54
name = "merge",
65
srcs = glob(
76
["**/*.ts"],
87
exclude = ["**/*.spec.ts"],
98
),
10-
module_name = "@angular/dev-infra-private/pr/merge",
9+
1110
# prodmode target must be set to es5 as the Ora class, which is extended is not a proper
1211
# prototyped object.
1312
prodmode_target = "es5",

dev-infra/pr/rebase/BUILD.bazel

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
load("@npm//@bazel/typescript:index.bzl", "ts_library")
1+
load("//dev-infra:defaults.bzl", "ts_library")
22

33
ts_library(
44
name = "rebase",
55
srcs = [
66
"cli.ts",
77
"index.ts",
88
],
9-
module_name = "@angular/dev-infra-private/pr/rebase",
109
visibility = ["//dev-infra:__subpackages__"],
1110
deps = [
1211
"//dev-infra/commit-message",

dev-infra/pullapprove/BUILD.bazel

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
load("@npm//@bazel/typescript:index.bzl", "ts_library")
2-
load("//tools:defaults.bzl", "jasmine_node_test")
1+
load("//dev-infra:defaults.bzl", "jasmine_node_test", "ts_library")
32

43
ts_library(
54
name = "pullapprove",
@@ -13,7 +12,6 @@ ts_library(
1312
"utils.ts",
1413
"verify.ts",
1514
],
16-
module_name = "@angular/dev-infra-private/pullapprove",
1715
visibility = ["//dev-infra:__subpackages__"],
1816
deps = [
1917
"//dev-infra/utils",

dev-infra/release/BUILD.bazel

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
load("@npm//@bazel/typescript:index.bzl", "ts_library")
1+
load("//dev-infra:defaults.bzl", "ts_library")
22

33
ts_library(
44
name = "release",
55
srcs = glob([
66
"**/*.ts",
77
]),
8-
module_name = "@angular/dev-infra-private/release",
98
visibility = ["//dev-infra:__subpackages__"],
109
deps = [
1110
"//dev-infra/release/build",

dev-infra/release/build/BUILD.bazel

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
load("@npm//@bazel/typescript:index.bzl", "ts_library")
2-
load("//tools:defaults.bzl", "jasmine_node_test")
1+
load("//dev-infra:defaults.bzl", "jasmine_node_test", "ts_library")
32

43
exports_files([
54
"build-worker.ts",
@@ -13,7 +12,6 @@ ts_library(
1312
],
1413
exclude = ["*.spec.ts"],
1514
),
16-
module_name = "@angular/dev-infra-private/release/build",
1715
visibility = ["//dev-infra:__subpackages__"],
1816
deps = [
1917
"//dev-infra/release/config",

dev-infra/release/config/BUILD.bazel

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
load("@npm//@bazel/typescript:index.bzl", "ts_library")
1+
load("//dev-infra:defaults.bzl", "ts_library")
22

33
ts_library(
44
name = "config",
55
srcs = glob([
66
"**/*.ts",
77
]),
8-
module_name = "@angular/dev-infra-private/release/config",
98
visibility = ["//dev-infra:__subpackages__"],
109
deps = [
1110
"//dev-infra/utils",

0 commit comments

Comments
 (0)