Skip to content

Commit 010a39f

Browse files
renovate-botdylhunn
authored andcommitted
build: update bazel (angular#45431)
Update `@bazel` packages to the latest 5.x version. Some of the changes here are modeled after angular/dev-infra@40c0ac8. Co-Authored-By: George Kalpakas <[email protected]> PR Close angular#45431
1 parent 05cd0e0 commit 010a39f

16 files changed

Lines changed: 140 additions & 97 deletions

File tree

BUILD.bazel

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary")
2+
13
package(default_visibility = ["//visibility:public"])
24

35
exports_files([
@@ -56,3 +58,10 @@ config_setting(
5658
name = "stamp",
5759
values = {"stamp": "true"},
5860
)
61+
62+
nodejs_binary(
63+
name = "yarn_vendored",
64+
data = [".yarn/releases/yarn-1.22.17.cjs"],
65+
entry_point = ".yarn/releases/yarn-1.22.17.cjs",
66+
visibility = ["//integration:__subpackages__"],
67+
)

WORKSPACE

Lines changed: 47 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,17 @@ workspace(
88

99
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
1010

11-
# Fetch rules_nodejs so we can install our npm dependencies
11+
# Fetch rules_nodejs and install its dependencies so we can install our npm dependencies.
1212
http_archive(
1313
name = "build_bazel_rules_nodejs",
14-
sha256 = "2644a66772938db8d8c760334a252f1687455daa7e188073f2d46283f2f6fbb7",
15-
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/4.6.2/rules_nodejs-4.6.2.tar.gz"],
14+
sha256 = "965ee2492a2b087cf9e0f2ca472aeaf1be2eb650e0cfbddf514b9a7d3ea4b02a",
15+
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.2.0/rules_nodejs-5.2.0.tar.gz"],
1616
)
1717

18+
load("@build_bazel_rules_nodejs//:repositories.bzl", "build_bazel_rules_nodejs_dependencies")
19+
20+
build_bazel_rules_nodejs_dependencies()
21+
1822
# The PKG rules are needed to build tar packages for integration tests. The builtin
1923
# rule in `@bazel_tools` is not Windows compatible and outdated.
2024
http_archive(
@@ -34,35 +38,61 @@ http_archive(
3438
url = "https://github.com/aspect-build/bazel-lib/archive/refs/tags/v0.5.0.tar.gz",
3539
)
3640

37-
# Check the rules_nodejs version and download npm dependencies
38-
# Note: bazel (version 2 and after) will check the .bazelversion file so we don't need to
39-
# assert on that.
40-
load("@build_bazel_rules_nodejs//:index.bzl", "check_rules_nodejs_version", "node_repositories", "yarn_install")
41+
# Setup the Node.js toolchain.
42+
load("@rules_nodejs//nodejs:repositories.bzl", "nodejs_register_toolchains")
4143

42-
check_rules_nodejs_version(minimum_version_string = "2.2.0")
43-
44-
# Setup the Node.js toolchain
45-
node_repositories(
44+
nodejs_register_toolchains(
45+
name = "nodejs",
4646
node_version = "16.10.0",
47-
package_json = ["//:package.json"],
4847
)
4948

49+
# Download npm dependencies.
50+
load("@build_bazel_rules_nodejs//:index.bzl", "yarn_install")
5051
load("//integration:npm_package_archives.bzl", "npm_package_archives")
5152

5253
yarn_install(
5354
name = "npm",
54-
# Note that we add the postinstall script here so that the dependencies are re-installed
55+
# Note that we add the postinstall scripts here so that the dependencies are re-installed
5556
# when the postinstall patches are modified.
56-
data = ["//tools:postinstall-patches.js"],
57+
data = [
58+
"//:.yarn/releases/yarn-1.22.17.cjs",
59+
"//:.yarnrc",
60+
"//:scripts/puppeteer-chromedriver-versions.js",
61+
"//:scripts/webdriver-manager-update.js",
62+
"//tools:postinstall-patches.js",
63+
],
64+
# Currently disabled due to:
65+
# 1. Missing Windows support currently.
66+
# 2. Incompatibilites with the `ts_library` rule.
67+
exports_directories_only = False,
5768
manual_build_file_contents = npm_package_archives(),
5869
package_json = "//:package.json",
70+
# We prefer to symlink the `node_modules` to only maintain a single install.
71+
# See https://github.com/angular/dev-infra/pull/446#issuecomment-1059820287 for details.
72+
symlink_node_modules = True,
73+
yarn = "//:.yarn/releases/yarn-1.22.17.cjs",
5974
yarn_lock = "//:yarn.lock",
6075
)
6176

6277
yarn_install(
6378
name = "aio_npm",
79+
# Note that we add the postinstall scripts here so that the dependencies are re-installed
80+
# when the postinstall patches are modified.
81+
data = [
82+
"//:.yarn/releases/yarn-1.22.17.cjs",
83+
"//:.yarnrc",
84+
"//aio:tools/cli-patches/patch.js",
85+
],
86+
# Currently disabled due to:
87+
# 1. Missing Windows support currently.
88+
# 2. Incompatibilites with the `ts_library` rule.
89+
exports_directories_only = False,
6490
manual_build_file_contents = npm_package_archives(),
6591
package_json = "//aio:package.json",
92+
# We prefer to symlink the `node_modules` to only maintain a single install.
93+
# See https://github.com/angular/dev-infra/pull/446#issuecomment-1059820287 for details.
94+
symlink_node_modules = True,
95+
yarn = "//:.yarn/releases/yarn-1.22.17.cjs",
6696
yarn_lock = "//aio:yarn.lock",
6797
)
6898

@@ -86,7 +116,9 @@ browser_repositories()
86116

87117
load("@build_bazel_rules_nodejs//toolchains/esbuild:esbuild_repositories.bzl", "esbuild_repositories")
88118

89-
esbuild_repositories()
119+
esbuild_repositories(
120+
npm_repository = "npm",
121+
)
90122

91123
load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies")
92124

devtools/tools/esbuild/index.bzl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,14 @@ def _linker_mapping_impl(ctx):
2323
sources = depset(ctx.files.srcs),
2424
),
2525
LinkerPackageMappingInfo(
26-
mappings = {
27-
ctx.attr.module_name: "%s/%s" % (ctx.label.package, ctx.attr.subpath),
28-
},
26+
mappings = depset([
27+
struct(
28+
package_name = ctx.attr.module_name,
29+
package_path = "",
30+
link_path = "%s/%s" % (ctx.label.package, ctx.attr.subpath),
31+
),
32+
]),
33+
node_modules_roots = depset([]),
2934
),
3035
]
3136

integration/bazel_workspace_tests/bazel_ngtsc_plugin/test/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("@npm//@bazel/typescript:index.bzl", "ts_library")
1+
load("@npm//@bazel/concatjs:index.bzl", "ts_library")
22

33
package(default_visibility = ["//visibility:public"])
44

integration/bazel_workspace_tests/bazel_ngtsc_plugin/test/e2e/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
load("@npm//@bazel/concatjs:index.bzl", "ts_library")
12
load("@npm//@bazel/protractor:index.bzl", "protractor_web_test_suite")
2-
load("@npm//@bazel/typescript:index.bzl", "ts_library")
33

44
ts_library(
55
name = "e2e",

integration/bazel_workspace_tests/bazel_ngtsc_plugin/tools/ng_ts_library.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"Shows how to enable both worker mode and use_angular_plugin to make a drop-in replacement for ng_module"
22

3-
load("@npm//@bazel/typescript:index.bzl", "ts_library")
3+
load("@npm//@bazel/concatjs:index.bzl", "ts_library")
44

55
def ng_ts_library(**kwargs):
66
angular_assets = kwargs.pop("assets", []) + kwargs.pop("angular_assets", [])

integration/index.bzl

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,6 @@ def _ng_integration_test(name, setup_chromium = False, **kwargs):
4141
track_payload_size = kwargs.pop("track_payload_size", None)
4242
data = kwargs.pop("data", [])
4343

44-
data += [
45-
# The Yarn files also need to be part of the integration test as runfiles
46-
# because the `yarn_bin` target is not a self-contained standalone binary.
47-
"@nodejs//:yarn_files",
48-
]
49-
5044
if setup_chromium:
5145
data += ["@npm//@angular/dev-infra-private/bazel/browsers/chromium"]
5246
toolchains += ["@npm//@angular/dev-infra-private/bazel/browsers/chromium:toolchain_alias"]
@@ -110,8 +104,8 @@ def _ng_integration_test(name, setup_chromium = False, **kwargs):
110104
environment = environment,
111105
toolchains = toolchains,
112106
tool_mappings = {
113-
"@nodejs//:yarn_bin": "yarn",
114-
"@nodejs//:node_bin": "node",
107+
"//:yarn_vendored": "yarn",
108+
"@nodejs_toolchains//:resolved_toolchain": "node",
115109
},
116110
# 15-minute timeout
117111
timeout = "long",

package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@
6565
"@babel/template": "7.16.7",
6666
"@babel/traverse": "7.17.3",
6767
"@babel/types": "7.17.0",
68-
"@bazel/concatjs": "4.6.0",
69-
"@bazel/esbuild": "4.6.0",
70-
"@bazel/jasmine": "4.6.0",
71-
"@bazel/protractor": "4.6.0",
72-
"@bazel/rollup": "4.6.0",
73-
"@bazel/runfiles": "4.6.0",
74-
"@bazel/terser": "4.6.0",
75-
"@bazel/typescript": "4.6.0",
68+
"@bazel/concatjs": "5.2.0",
69+
"@bazel/esbuild": "5.2.0",
70+
"@bazel/jasmine": "5.2.0",
71+
"@bazel/protractor": "5.2.0",
72+
"@bazel/rollup": "5.2.0",
73+
"@bazel/runfiles": "5.2.0",
74+
"@bazel/terser": "5.2.0",
75+
"@bazel/typescript": "5.2.0",
7676
"@microsoft/api-extractor": "7.19.4",
7777
"@rollup/plugin-babel": "^5.3.0",
7878
"@rollup/plugin-commonjs": "^21.0.0",
@@ -179,7 +179,7 @@
179179
"devDependencies": {
180180
"@angular/dev-infra-private": "https://github.com/angular/dev-infra-private-builds.git#5a82e6017227f7017c76c8117bcbf975e19ef894",
181181
"@bazel/bazelisk": "^1.7.5",
182-
"@bazel/buildifier": "^4.0.1",
182+
"@bazel/buildifier": "^5.0.0",
183183
"@bazel/ibazel": "^0.15.8",
184184
"@octokit/graphql": "^4.6.1",
185185
"@types/browser-sync": "^2.26.1",

packages/bazel/src/external.bzl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
"""
33

44
load(
5-
# Replaced with "//@bazel/typescript/internal:..." in published package
6-
"@npm//@bazel/typescript/internal:build_defs.bzl",
5+
# Replaced with "//@bazel/concatjs/internal:..." in published package
6+
"@npm//@bazel/concatjs/internal:build_defs.bzl",
77
_tsc_wrapped_tsconfig = "tsc_wrapped_tsconfig",
88
)
99
load(
10-
# Replaced with "//@bazel/typescript/internal:..." in published package
11-
"@npm//@bazel/typescript/internal:common/compilation.bzl",
10+
# Replaced with "//@bazel/concatjs/internal:..." in published package
11+
"@npm//@bazel/concatjs/internal:common/compilation.bzl",
1212
_COMMON_ATTRIBUTES = "COMMON_ATTRIBUTES",
1313
_COMMON_OUTPUTS = "COMMON_OUTPUTS",
1414
_DEPS_ASPECTS = "DEPS_ASPECTS",
@@ -25,10 +25,13 @@ load(
2525
_LinkablePackageInfo = "LinkablePackageInfo",
2626
_NpmPackageInfo = "NpmPackageInfo",
2727
_js_ecma_script_module_info = "js_ecma_script_module_info",
28-
_js_module_info = "js_module_info",
2928
_js_named_module_info = "js_named_module_info",
3029
_node_modules_aspect = "node_modules_aspect",
3130
)
31+
load(
32+
"@rules_nodejs//nodejs:providers.bzl",
33+
_js_module_info = "js_module_info",
34+
)
3235

3336
LinkablePackageInfo = _LinkablePackageInfo
3437
NpmPackageInfo = _NpmPackageInfo

packages/bazel/src/ng_package/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary")
22

33
# BEGIN-DEV-ONLY
4-
load("@npm//@bazel/typescript:index.bzl", "ts_library")
4+
load("@npm//@bazel/concatjs:index.bzl", "ts_library")
55
# END-DEV-ONLY
66

77
package(default_visibility = ["//visibility:public"])

0 commit comments

Comments
 (0)