Skip to content

build: update bazel setup to rules_nodejs v0.38.0 #17249

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
# Add NodeJS rules (explicitly used for sass bundle rules)
http_archive(
name = "build_bazel_rules_nodejs",
sha256 = "da217044d24abd16667324626a33581f3eaccabf80985b2688d6a08ed2f864be",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/0.37.1/rules_nodejs-0.37.1.tar.gz"],
sha256 = "1249a60f88e4c0a46d78de06be04d3d41e7421dcfa0c956de65309a7b7ecf6f4",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/0.38.0/rules_nodejs-0.38.0.tar.gz"],
)

# Add sass rules
Expand Down Expand Up @@ -39,6 +39,7 @@ yarn_install(
# are executed in the Bazel sandbox.
data = [
"//:angular-tsconfig.json",
"//:tools/bazel/angular_bazel_0.38.0.patch",
"//:tools/bazel/flat_module_factory_resolution.patch",
"//:tools/bazel/manifest_externs_hermeticity.patch",
"//:tools/bazel/postinstall-patches.js",
Expand All @@ -59,14 +60,14 @@ load("@npm//:install_bazel_dependencies.bzl", "install_bazel_dependencies")
install_bazel_dependencies()

# Setup TypeScript Bazel workspace
load("@npm_bazel_typescript//:defs.bzl", "ts_setup_workspace")
load("@npm_bazel_typescript//:index.bzl", "ts_setup_workspace")

ts_setup_workspace()

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

rules_karma_dependencies()
npm_bazel_karma_dependencies()

# Setup web testing. We need to setup a browser because the web testing rules for TypeScript need
# a reference to a registered browser (ideally that's a hermetic version of a browser)
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@
"@angular/router": "^9.0.0-next.7",
"@angular/upgrade": "^9.0.0-next.7",
"@bazel/bazel": "^0.29.0",
"@bazel/buildifier": "^0.28.0",
"@bazel/buildifier": "^0.29.0",
"@bazel/ibazel": "^0.10.3",
"@bazel/jasmine": "^0.37.1",
"@bazel/karma": "^0.37.1",
"@bazel/typescript": "^0.37.1",
"@bazel/protractor": "^0.37.1",
"@bazel/jasmine": "^0.38.0",
"@bazel/karma": "^0.38.0",
"@bazel/typescript": "^0.38.0",
"@bazel/protractor": "^0.38.0",
"@firebase/app-types": "^0.3.2",
"@octokit/rest": "^16.28.7",
"@schematics/angular": "^9.0.0-next.5",
Expand Down
2 changes: 1 addition & 1 deletion src/e2e-app/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package(default_visibility = ["//visibility:public"])

load("@io_bazel_rules_sass//:defs.bzl", "sass_binary")
load("@npm_bazel_typescript//:defs.bzl", "ts_devserver")
load("@npm_bazel_typescript//:index.bzl", "ts_devserver")
load("//:packages.bzl", "ANGULAR_LIBRARY_UMDS")
load("//tools:defaults.bzl", "ng_module")

Expand Down
48 changes: 48 additions & 0 deletions tools/bazel/angular_bazel_0.38.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
diff --git node_modules/@angular/bazel/src/esm5.bzl node_modules/@angular/bazel/src/esm5.bzl
index 98315468fb44..22903a9d772d 100644
--- node_modules/@angular/bazel/src/esm5.bzl
+++ node_modules/@angular/bazel/src/esm5.bzl
@@ -30,7 +30,7 @@ ESM5Info = provider(
)

def _map_closure_path(file):
- result = file.short_path[:-len(".closure.js")]
+ result = file.short_path[:-len(".mjs")]

# short_path is meant to be used when accessing runfiles in a binary, where
# the CWD is inside the current repo. Therefore files in external repo have a
diff --git node_modules/@angular/bazel/src/modify_tsconfig.js node_modules/@angular/bazel/src/modify_tsconfig.js
index 9d3c491598c3..3c997462b247 100644
--- node_modules/@angular/bazel/src/modify_tsconfig.js
+++ node_modules/@angular/bazel/src/modify_tsconfig.js
@@ -44,7 +44,7 @@ function main(args) {
// ngc-wrapped is expecting POSIX paths and the TypeScript Bazel rules by default only pass
// POSIX paths as well.
angularCompilerOptions['expectedOut'] = angularCompilerOptions['expectedOut'].map(
- f => f.replace(/\.closure\.js$/, '.js').replace(binDir, newOutputBase));
+ f => f.replace(/\.mjs$/, '.js').replace(binDir, newOutputBase));
}
fs.writeFileSync(output, JSON.stringify(data));
}
diff --git node_modules/@angular/bazel/src/ng_module.bzl node_modules/@angular/bazel/src/ng_module.bzl
index 9b88fbb51c2e..d2eb8aa135f4 100644
--- node_modules/@angular/bazel/src/ng_module.bzl
+++ node_modules/@angular/bazel/src/ng_module.bzl
@@ -237,7 +237,7 @@ def _expected_outs(ctx):
continue

filter_summaries = ctx.attr.filter_summaries
- closure_js = [f.replace(".js", ".closure.js") for f in devmode_js if not filter_summaries or not f.endswith(".ngsummary.js")]
+ closure_js = [f.replace(".js", ".mjs") for f in devmode_js if not filter_summaries or not f.endswith(".ngsummary.js")]
declarations = [f.replace(".js", ".d.ts") for f in devmode_js]

devmode_js_files += [ctx.actions.declare_file(basename + ext) for ext in devmode_js]
@@ -262,7 +262,7 @@ def _expected_outs(ctx):
if _should_produce_flat_module_outs(ctx):
flat_module_out = _flat_module_out_file(ctx)
devmode_js_files.append(ctx.actions.declare_file("%s.js" % flat_module_out))
- closure_js_files.append(ctx.actions.declare_file("%s.closure.js" % flat_module_out))
+ closure_js_files.append(ctx.actions.declare_file("%s.mjs" % flat_module_out))
bundle_index_typings = ctx.actions.declare_file("%s.d.ts" % flat_module_out)
declaration_files.append(bundle_index_typings)
if is_legacy_ngc:
6 changes: 6 additions & 0 deletions tools/bazel/postinstall-patches.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ searchAndReplace(
// Workaround for: https://github.com/bazelbuild/rules_nodejs/issues/1208.
shelljs.cat(path.join(__dirname, './manifest_externs_hermeticity.patch')).exec('patch -p0');

// Patches https://github.com/angular/angular/pull/32889 into our "@angular/bazel"
// installation. We need to patch it because otherwise the @angular/bazel PR cannot land
// as the "component-unit-tests" job will fail due to not being updated to 0.38.0. Either
// the framework or component repo needs to be patched to unblock the cyclic dependency.
shelljs.cat(path.join(__dirname, './angular_bazel_0.38.0.patch')).exec('patch -p0');

/**
* Reads the specified file and replaces matches of the search expression
* with the given replacement. Throws if no changes were made.
Expand Down
4 changes: 2 additions & 2 deletions tools/defaults.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

load("@npm_angular_bazel//:index.bzl", _ng_module = "ng_module", _ng_package = "ng_package")
load("@npm_bazel_jasmine//:index.bzl", _jasmine_node_test = "jasmine_node_test")
load("@npm_bazel_karma//:defs.bzl", _karma_web_test_suite = "karma_web_test_suite")
load("@npm_bazel_karma//:index.bzl", _karma_web_test_suite = "karma_web_test_suite")
load("@npm_bazel_protractor//:index.bzl", _protractor_web_test_suite = "protractor_web_test_suite")
load("@npm_bazel_typescript//:defs.bzl", _ts_library = "ts_library")
load("@npm_bazel_typescript//:index.bzl", _ts_library = "ts_library")
load("//:packages.bzl", "ANGULAR_LIBRARY_UMDS", "VERSION_PLACEHOLDER_REPLACEMENTS")
load("//:rollup-globals.bzl", "ROLLUP_GLOBALS")
load("//tools/markdown-to-html:index.bzl", _markdown_to_html = "markdown_to_html")
Expand Down
76 changes: 38 additions & 38 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -306,29 +306,29 @@
"@bazel/bazel-linux_x64" "0.29.0"
"@bazel/bazel-win32_x64" "0.29.0"

"@bazel/buildifier-darwin_x64@0.28.0":
version "0.28.0"
resolved "https://registry.yarnpkg.com/@bazel/buildifier-darwin_x64/-/buildifier-darwin_x64-0.28.0.tgz#bc8c4312596d4cf321062ae4e3f2115be453fef2"
integrity sha512-bvWz4W3FzWFqUr65Z/IrrhUuzHzvFnYB3QpPXUlUOI1sx43Ge3pMlndEwhMBOPM2SoRi5Z5rxG0X9NuvuXWw8w==

"@bazel/buildifier-linux_x64@0.28.0":
version "0.28.0"
resolved "https://registry.yarnpkg.com/@bazel/buildifier-linux_x64/-/buildifier-linux_x64-0.28.0.tgz#d09dedcfcd1677ddec8fe17fa7e39612dab86b41"
integrity sha512-KVXUcT2yZnKcRf4L9qzlYtEHw9SdO4/O6/cyyyybYPzpS3CJ2yIFm6VabXBTXsUp3LXfWc3EE62f8ieHoRJJnw==

"@bazel/buildifier-win32_x64@0.28.0":
version "0.28.0"
resolved "https://registry.yarnpkg.com/@bazel/buildifier-win32_x64/-/buildifier-win32_x64-0.28.0.tgz#1d2c239753a389f48669a194bf16477c1f15befd"
integrity sha512-6E9QZPVzMolcQQKDi5tRJjAFylgzBWbV01/3RiFZb1x4ITZJ74h/FuTRhdYAUPA3n59ge2F3sPtf9Q97RxJU7g==

"@bazel/buildifier@^0.28.0":
version "0.28.0"
resolved "https://registry.yarnpkg.com/@bazel/buildifier/-/buildifier-0.28.0.tgz#cce8a5b67520f27b611c149bf334b5f86e5e5aa7"
integrity sha512-g9F7rEQayXU4SHgbOYhDLk8AzDMhqFNnZVb/xVDeCkbg20MbCGIZDj9pN8NBnowB7OJF4VsvnSV0FB4BVGfpxQ==
"@bazel/buildifier-darwin_x64@0.29.0":
version "0.29.0"
resolved "https://registry.yarnpkg.com/@bazel/buildifier-darwin_x64/-/buildifier-darwin_x64-0.29.0.tgz#13dfaf3ea4d89f9d4da00085e894e90b7d302342"
integrity sha512-jiQIZo5z1c8oFokD2jObrkB04Bs+7RaUJ6WlHV9BBeJiRMGfRVUBUrOF5eJPk6VB8qknIOfHvJD/Ym5XUc1Zlw==

"@bazel/buildifier-linux_x64@0.29.0":
version "0.29.0"
resolved "https://registry.yarnpkg.com/@bazel/buildifier-linux_x64/-/buildifier-linux_x64-0.29.0.tgz#0191fc46735a1c281878642673844f2b717cd8dc"
integrity sha512-sXXY0gP4oC1nC1G8Baqd7kyBL/y9/qOqftKSkDe2Y7gBoc9GslwyexwDxTSxK0Gun/4Vcvc2eRu7b83hMOxuag==

"@bazel/buildifier-win32_x64@0.29.0":
version "0.29.0"
resolved "https://registry.yarnpkg.com/@bazel/buildifier-win32_x64/-/buildifier-win32_x64-0.29.0.tgz#a63438c7a7d2dc593e626ed6e163e9d8ea93917a"
integrity sha512-hnOQfPhQNAIqbrhsHT3MWAyAZSUhKwxzEuZJZoOsGrW8fPonhKysdvfZJqfqJ6vDVYaMJKvLnSO1c9QZRhU7kQ==

"@bazel/buildifier@^0.29.0":
version "0.29.0"
resolved "https://registry.yarnpkg.com/@bazel/buildifier/-/buildifier-0.29.0.tgz#7984739270c8d1dd23650f87a810e1e6367188d9"
integrity sha512-skJ7vVff7x3tB8crBCtJji2wU09uH0uD2N30xfOpVUgsMJSXktAQMj8+RPdMBqJQ9XS5+O5lmRthR35Ua7xQXA==
optionalDependencies:
"@bazel/buildifier-darwin_x64" "0.28.0"
"@bazel/buildifier-linux_x64" "0.28.0"
"@bazel/buildifier-win32_x64" "0.28.0"
"@bazel/buildifier-darwin_x64" "0.29.0"
"@bazel/buildifier-linux_x64" "0.29.0"
"@bazel/buildifier-win32_x64" "0.29.0"

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

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

"@bazel/karma@^0.37.1":
version "0.37.1"
resolved "https://registry.yarnpkg.com/@bazel/karma/-/karma-0.37.1.tgz#1c2ba937f8a2a442a629d4edd5219c3623192b12"
integrity sha512-LwcvQkZJvlSWf7jvZY48GG1PJFINDrKHp59hupK8tTWN726sAAoQzQUp8ZO0e/pHKGcl4X6AvqWw3+MvXsGS7Q==
"@bazel/karma@^0.38.0":
version "0.38.0"
resolved "https://registry.yarnpkg.com/@bazel/karma/-/karma-0.38.0.tgz#c738f769691196884f985c18a903b326c152854f"
integrity sha512-toDlcQy6z69D/aZfzzkWjWd4eAn0gxwJmfCnomsC/P56mWEsFNj1BBjuINEd8xcQhXyBi8q1zHa9MyAoDqrYWQ==
dependencies:
jasmine-core "2.8.0"
karma "^4.0.0"
Expand All @@ -366,17 +366,17 @@
semver "5.6.0"
tmp "0.0.33"

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

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