Skip to content

Commit 65a8c96

Browse files
devversionjelbourn
authored andcommitted
build: update bazel setup to rules_nodejs v0.38.0 (#17249)
Updates the `rules_nodejs` version to the latest version. This is necessary to stay up-to-date and to unblock framework which also wants to update to `rules_nodejs#0.38.0`. This unblocks: angular/angular#32889.
1 parent 4c6e6ea commit 65a8c96

File tree

7 files changed

+106
-51
lines changed

7 files changed

+106
-51
lines changed

WORKSPACE

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
55
# Add NodeJS rules (explicitly used for sass bundle rules)
66
http_archive(
77
name = "build_bazel_rules_nodejs",
8-
sha256 = "da217044d24abd16667324626a33581f3eaccabf80985b2688d6a08ed2f864be",
9-
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/0.37.1/rules_nodejs-0.37.1.tar.gz"],
8+
sha256 = "1249a60f88e4c0a46d78de06be04d3d41e7421dcfa0c956de65309a7b7ecf6f4",
9+
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/0.38.0/rules_nodejs-0.38.0.tar.gz"],
1010
)
1111

1212
# Add sass rules
@@ -39,6 +39,7 @@ yarn_install(
3939
# are executed in the Bazel sandbox.
4040
data = [
4141
"//:angular-tsconfig.json",
42+
"//:tools/bazel/angular_bazel_0.38.0.patch",
4243
"//:tools/bazel/flat_module_factory_resolution.patch",
4344
"//:tools/bazel/manifest_externs_hermeticity.patch",
4445
"//:tools/bazel/postinstall-patches.js",
@@ -59,14 +60,14 @@ load("@npm//:install_bazel_dependencies.bzl", "install_bazel_dependencies")
5960
install_bazel_dependencies()
6061

6162
# Setup TypeScript Bazel workspace
62-
load("@npm_bazel_typescript//:defs.bzl", "ts_setup_workspace")
63+
load("@npm_bazel_typescript//:index.bzl", "ts_setup_workspace")
6364

6465
ts_setup_workspace()
6566

6667
# Fetch transitive dependencies which are needed to use the karma rules.
67-
load("@npm_bazel_karma//:package.bzl", "rules_karma_dependencies")
68+
load("@npm_bazel_karma//:package.bzl", "npm_bazel_karma_dependencies")
6869

69-
rules_karma_dependencies()
70+
npm_bazel_karma_dependencies()
7071

7172
# Setup web testing. We need to setup a browser because the web testing rules for TypeScript need
7273
# a reference to a registered browser (ideally that's a hermetic version of a browser)

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@
6868
"@angular/router": "^9.0.0-next.7",
6969
"@angular/upgrade": "^9.0.0-next.7",
7070
"@bazel/bazel": "^0.29.0",
71-
"@bazel/buildifier": "^0.28.0",
71+
"@bazel/buildifier": "^0.29.0",
7272
"@bazel/ibazel": "^0.10.3",
73-
"@bazel/jasmine": "^0.37.1",
74-
"@bazel/karma": "^0.37.1",
75-
"@bazel/typescript": "^0.37.1",
76-
"@bazel/protractor": "^0.37.1",
73+
"@bazel/jasmine": "^0.38.0",
74+
"@bazel/karma": "^0.38.0",
75+
"@bazel/typescript": "^0.38.0",
76+
"@bazel/protractor": "^0.38.0",
7777
"@firebase/app-types": "^0.3.2",
7878
"@octokit/rest": "^16.28.7",
7979
"@schematics/angular": "^9.0.0-next.5",

src/e2e-app/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package(default_visibility = ["//visibility:public"])
22

33
load("@io_bazel_rules_sass//:defs.bzl", "sass_binary")
4-
load("@npm_bazel_typescript//:defs.bzl", "ts_devserver")
4+
load("@npm_bazel_typescript//:index.bzl", "ts_devserver")
55
load("//:packages.bzl", "ANGULAR_LIBRARY_UMDS")
66
load("//tools:defaults.bzl", "ng_module")
77

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
diff --git node_modules/@angular/bazel/src/esm5.bzl node_modules/@angular/bazel/src/esm5.bzl
2+
index 98315468fb44..22903a9d772d 100644
3+
--- node_modules/@angular/bazel/src/esm5.bzl
4+
+++ node_modules/@angular/bazel/src/esm5.bzl
5+
@@ -30,7 +30,7 @@ ESM5Info = provider(
6+
)
7+
8+
def _map_closure_path(file):
9+
- result = file.short_path[:-len(".closure.js")]
10+
+ result = file.short_path[:-len(".mjs")]
11+
12+
# short_path is meant to be used when accessing runfiles in a binary, where
13+
# the CWD is inside the current repo. Therefore files in external repo have a
14+
diff --git node_modules/@angular/bazel/src/modify_tsconfig.js node_modules/@angular/bazel/src/modify_tsconfig.js
15+
index 9d3c491598c3..3c997462b247 100644
16+
--- node_modules/@angular/bazel/src/modify_tsconfig.js
17+
+++ node_modules/@angular/bazel/src/modify_tsconfig.js
18+
@@ -44,7 +44,7 @@ function main(args) {
19+
// ngc-wrapped is expecting POSIX paths and the TypeScript Bazel rules by default only pass
20+
// POSIX paths as well.
21+
angularCompilerOptions['expectedOut'] = angularCompilerOptions['expectedOut'].map(
22+
- f => f.replace(/\.closure\.js$/, '.js').replace(binDir, newOutputBase));
23+
+ f => f.replace(/\.mjs$/, '.js').replace(binDir, newOutputBase));
24+
}
25+
fs.writeFileSync(output, JSON.stringify(data));
26+
}
27+
diff --git node_modules/@angular/bazel/src/ng_module.bzl node_modules/@angular/bazel/src/ng_module.bzl
28+
index 9b88fbb51c2e..d2eb8aa135f4 100644
29+
--- node_modules/@angular/bazel/src/ng_module.bzl
30+
+++ node_modules/@angular/bazel/src/ng_module.bzl
31+
@@ -237,7 +237,7 @@ def _expected_outs(ctx):
32+
continue
33+
34+
filter_summaries = ctx.attr.filter_summaries
35+
- closure_js = [f.replace(".js", ".closure.js") for f in devmode_js if not filter_summaries or not f.endswith(".ngsummary.js")]
36+
+ closure_js = [f.replace(".js", ".mjs") for f in devmode_js if not filter_summaries or not f.endswith(".ngsummary.js")]
37+
declarations = [f.replace(".js", ".d.ts") for f in devmode_js]
38+
39+
devmode_js_files += [ctx.actions.declare_file(basename + ext) for ext in devmode_js]
40+
@@ -262,7 +262,7 @@ def _expected_outs(ctx):
41+
if _should_produce_flat_module_outs(ctx):
42+
flat_module_out = _flat_module_out_file(ctx)
43+
devmode_js_files.append(ctx.actions.declare_file("%s.js" % flat_module_out))
44+
- closure_js_files.append(ctx.actions.declare_file("%s.closure.js" % flat_module_out))
45+
+ closure_js_files.append(ctx.actions.declare_file("%s.mjs" % flat_module_out))
46+
bundle_index_typings = ctx.actions.declare_file("%s.d.ts" % flat_module_out)
47+
declaration_files.append(bundle_index_typings)
48+
if is_legacy_ngc:

tools/bazel/postinstall-patches.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@ searchAndReplace(
9999
// Workaround for: https://github.com/bazelbuild/rules_nodejs/issues/1208.
100100
shelljs.cat(path.join(__dirname, './manifest_externs_hermeticity.patch')).exec('patch -p0');
101101

102+
// Patches https://github.com/angular/angular/pull/32889 into our "@angular/bazel"
103+
// installation. We need to patch it because otherwise the @angular/bazel PR cannot land
104+
// as the "component-unit-tests" job will fail due to not being updated to 0.38.0. Either
105+
// the framework or component repo needs to be patched to unblock the cyclic dependency.
106+
shelljs.cat(path.join(__dirname, './angular_bazel_0.38.0.patch')).exec('patch -p0');
107+
102108
/**
103109
* Reads the specified file and replaces matches of the search expression
104110
* with the given replacement. Throws if no changes were made.

tools/defaults.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
load("@npm_angular_bazel//:index.bzl", _ng_module = "ng_module", _ng_package = "ng_package")
44
load("@npm_bazel_jasmine//:index.bzl", _jasmine_node_test = "jasmine_node_test")
5-
load("@npm_bazel_karma//:defs.bzl", _karma_web_test_suite = "karma_web_test_suite")
5+
load("@npm_bazel_karma//:index.bzl", _karma_web_test_suite = "karma_web_test_suite")
66
load("@npm_bazel_protractor//:index.bzl", _protractor_web_test_suite = "protractor_web_test_suite")
7-
load("@npm_bazel_typescript//:defs.bzl", _ts_library = "ts_library")
7+
load("@npm_bazel_typescript//:index.bzl", _ts_library = "ts_library")
88
load("//:packages.bzl", "ANGULAR_LIBRARY_UMDS", "VERSION_PLACEHOLDER_REPLACEMENTS")
99
load("//:rollup-globals.bzl", "ROLLUP_GLOBALS")
1010
load("//tools/markdown-to-html:index.bzl", _markdown_to_html = "markdown_to_html")

yarn.lock

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -306,29 +306,29 @@
306306
"@bazel/bazel-linux_x64" "0.29.0"
307307
"@bazel/bazel-win32_x64" "0.29.0"
308308

309-
"@bazel/buildifier-darwin_x64@0.28.0":
310-
version "0.28.0"
311-
resolved "https://registry.yarnpkg.com/@bazel/buildifier-darwin_x64/-/buildifier-darwin_x64-0.28.0.tgz#bc8c4312596d4cf321062ae4e3f2115be453fef2"
312-
integrity sha512-bvWz4W3FzWFqUr65Z/IrrhUuzHzvFnYB3QpPXUlUOI1sx43Ge3pMlndEwhMBOPM2SoRi5Z5rxG0X9NuvuXWw8w==
313-
314-
"@bazel/buildifier-linux_x64@0.28.0":
315-
version "0.28.0"
316-
resolved "https://registry.yarnpkg.com/@bazel/buildifier-linux_x64/-/buildifier-linux_x64-0.28.0.tgz#d09dedcfcd1677ddec8fe17fa7e39612dab86b41"
317-
integrity sha512-KVXUcT2yZnKcRf4L9qzlYtEHw9SdO4/O6/cyyyybYPzpS3CJ2yIFm6VabXBTXsUp3LXfWc3EE62f8ieHoRJJnw==
318-
319-
"@bazel/buildifier-win32_x64@0.28.0":
320-
version "0.28.0"
321-
resolved "https://registry.yarnpkg.com/@bazel/buildifier-win32_x64/-/buildifier-win32_x64-0.28.0.tgz#1d2c239753a389f48669a194bf16477c1f15befd"
322-
integrity sha512-6E9QZPVzMolcQQKDi5tRJjAFylgzBWbV01/3RiFZb1x4ITZJ74h/FuTRhdYAUPA3n59ge2F3sPtf9Q97RxJU7g==
323-
324-
"@bazel/buildifier@^0.28.0":
325-
version "0.28.0"
326-
resolved "https://registry.yarnpkg.com/@bazel/buildifier/-/buildifier-0.28.0.tgz#cce8a5b67520f27b611c149bf334b5f86e5e5aa7"
327-
integrity sha512-g9F7rEQayXU4SHgbOYhDLk8AzDMhqFNnZVb/xVDeCkbg20MbCGIZDj9pN8NBnowB7OJF4VsvnSV0FB4BVGfpxQ==
309+
"@bazel/buildifier-darwin_x64@0.29.0":
310+
version "0.29.0"
311+
resolved "https://registry.yarnpkg.com/@bazel/buildifier-darwin_x64/-/buildifier-darwin_x64-0.29.0.tgz#13dfaf3ea4d89f9d4da00085e894e90b7d302342"
312+
integrity sha512-jiQIZo5z1c8oFokD2jObrkB04Bs+7RaUJ6WlHV9BBeJiRMGfRVUBUrOF5eJPk6VB8qknIOfHvJD/Ym5XUc1Zlw==
313+
314+
"@bazel/buildifier-linux_x64@0.29.0":
315+
version "0.29.0"
316+
resolved "https://registry.yarnpkg.com/@bazel/buildifier-linux_x64/-/buildifier-linux_x64-0.29.0.tgz#0191fc46735a1c281878642673844f2b717cd8dc"
317+
integrity sha512-sXXY0gP4oC1nC1G8Baqd7kyBL/y9/qOqftKSkDe2Y7gBoc9GslwyexwDxTSxK0Gun/4Vcvc2eRu7b83hMOxuag==
318+
319+
"@bazel/buildifier-win32_x64@0.29.0":
320+
version "0.29.0"
321+
resolved "https://registry.yarnpkg.com/@bazel/buildifier-win32_x64/-/buildifier-win32_x64-0.29.0.tgz#a63438c7a7d2dc593e626ed6e163e9d8ea93917a"
322+
integrity sha512-hnOQfPhQNAIqbrhsHT3MWAyAZSUhKwxzEuZJZoOsGrW8fPonhKysdvfZJqfqJ6vDVYaMJKvLnSO1c9QZRhU7kQ==
323+
324+
"@bazel/buildifier@^0.29.0":
325+
version "0.29.0"
326+
resolved "https://registry.yarnpkg.com/@bazel/buildifier/-/buildifier-0.29.0.tgz#7984739270c8d1dd23650f87a810e1e6367188d9"
327+
integrity sha512-skJ7vVff7x3tB8crBCtJji2wU09uH0uD2N30xfOpVUgsMJSXktAQMj8+RPdMBqJQ9XS5+O5lmRthR35Ua7xQXA==
328328
optionalDependencies:
329-
"@bazel/buildifier-darwin_x64" "0.28.0"
330-
"@bazel/buildifier-linux_x64" "0.28.0"
331-
"@bazel/buildifier-win32_x64" "0.28.0"
329+
"@bazel/buildifier-darwin_x64" "0.29.0"
330+
"@bazel/buildifier-linux_x64" "0.29.0"
331+
"@bazel/buildifier-win32_x64" "0.29.0"
332332

333333
"@bazel/hide-bazel-files@latest":
334334
version "0.35.0"
@@ -340,19 +340,19 @@
340340
resolved "https://registry.yarnpkg.com/@bazel/ibazel/-/ibazel-0.10.3.tgz#2e2b8a1d3e885946eac41db2b1aa6801fb319887"
341341
integrity sha512-v1nXbMTHVlMM4z4uWp6XiRoHAyUlYggF1SOboLLWRp0+D22kWixqArWqnozLw2mOtnxr97BdLjluWiho6A8Hjg==
342342

343-
"@bazel/jasmine@^0.37.1":
344-
version "0.37.1"
345-
resolved "https://registry.yarnpkg.com/@bazel/jasmine/-/jasmine-0.37.1.tgz#e5111f4f913b542cbfad767e0f903be026246c5a"
346-
integrity sha512-EQJ2bbmF3w+BeoCMEDY8mKd5lrVuZ4tEc1wqth4Jl2UIYwyEepDAKVMiEeM+seXxmzqle38ksdsf7uSUWMjthA==
343+
"@bazel/jasmine@^0.38.0":
344+
version "0.38.0"
345+
resolved "https://registry.yarnpkg.com/@bazel/jasmine/-/jasmine-0.38.0.tgz#d40bc3fa5b9cdaf9125ff422a1ed5fc25c41203e"
346+
integrity sha512-p4faogKschhMiZ4+g5z0On0VkhQzjsa4gCg8WMbHbxwSrjMYVQmiwqwEtNN2jBV0mqRRKOvRrH7O1snD2MyihA==
347347
dependencies:
348348
jasmine "~3.4.0"
349349
jasmine-core "~3.4.0"
350350
v8-coverage "1.0.9"
351351

352-
"@bazel/karma@^0.37.1":
353-
version "0.37.1"
354-
resolved "https://registry.yarnpkg.com/@bazel/karma/-/karma-0.37.1.tgz#1c2ba937f8a2a442a629d4edd5219c3623192b12"
355-
integrity sha512-LwcvQkZJvlSWf7jvZY48GG1PJFINDrKHp59hupK8tTWN726sAAoQzQUp8ZO0e/pHKGcl4X6AvqWw3+MvXsGS7Q==
352+
"@bazel/karma@^0.38.0":
353+
version "0.38.0"
354+
resolved "https://registry.yarnpkg.com/@bazel/karma/-/karma-0.38.0.tgz#c738f769691196884f985c18a903b326c152854f"
355+
integrity sha512-toDlcQy6z69D/aZfzzkWjWd4eAn0gxwJmfCnomsC/P56mWEsFNj1BBjuINEd8xcQhXyBi8q1zHa9MyAoDqrYWQ==
356356
dependencies:
357357
jasmine-core "2.8.0"
358358
karma "^4.0.0"
@@ -366,17 +366,17 @@
366366
semver "5.6.0"
367367
tmp "0.0.33"
368368

369-
"@bazel/protractor@^0.37.1":
370-
version "0.37.1"
371-
resolved "https://registry.yarnpkg.com/@bazel/protractor/-/protractor-0.37.1.tgz#932aaac40a4fc87a62e3ee52f9d748accf339032"
372-
integrity sha512-kJNVOlPXhTIuZ7Hfjy4+QPSnj0lifvgw/mFUvP1C+XSlZGV9Jg2FfxX6t7gwl0AI6NXFb5JWOG/igL7W3dJ+hA==
369+
"@bazel/protractor@^0.38.0":
370+
version "0.38.0"
371+
resolved "https://registry.yarnpkg.com/@bazel/protractor/-/protractor-0.38.0.tgz#08be006d29543fc3c417c4d9f59e1eb927bb2fa6"
372+
integrity sha512-omvQwYjvMTd6/xI9WNDfscl9GVhuaXs+lahhv2b7D3DGUuVStihQp4Ux4/xT6jlmOkru2uk38nfes/jfOoalkQ==
373373
dependencies:
374374
protractor "^5.4.2"
375375

376-
"@bazel/typescript@^0.37.1":
377-
version "0.37.1"
378-
resolved "https://registry.yarnpkg.com/@bazel/typescript/-/typescript-0.37.1.tgz#e740f311597dc0ed9d479ae7a88ea35cb2411e34"
379-
integrity sha512-RrZ6rYZTQz0tSwGIGoKykNkhpu8xY3IOAzLA3cmtpNa0pCGEb+PpFBlh//wjcnP8jLg5vK2Qa6jh3SZ2pcYZbg==
376+
"@bazel/typescript@^0.38.0":
377+
version "0.38.0"
378+
resolved "https://registry.yarnpkg.com/@bazel/typescript/-/typescript-0.38.0.tgz#0fce6ac5618a11bf7a9803455c24dbdcdf4a85cd"
379+
integrity sha512-3xZNQ1aHBRMPvxyDUR7yHxT5o/2IUkZh0s/eMMBB9GvU/uit0HpxOOdEADHqoID/8afU0SPYX0LKw+jDn6tfFA==
380380
dependencies:
381381
protobufjs "6.8.8"
382382
semver "5.6.0"

0 commit comments

Comments
 (0)