Skip to content

Commit db56cf1

Browse files
gregmagolanjosephperrott
authored andcommitted
build: upgrade angular build, integration/bazel and @angular/bazel package to rule_nodejs 2.2.0 (angular#37727)
Updates to rules_nodejs 2.2.0. This is the first major release in 7 months and includes a number of features as well as breaking changes. Release notes: https://github.com/bazelbuild/rules_nodejs/releases/tag/2.0.0 Features of note for angular/angular: * stdout/stderr/exit code capture; this could be potentially be useful * TypeScript (ts_project); a simpler tsc rule that ts_library that can be used in the repo where ts_library is too heavy weight Breaking changes of note for angular/angular: * loading custom rules from npm packages: `ts_library` is no longer loaded from `@npm_bazel_typescript//:index.bzl` (which no longer exists) but is now loaded from `@npm//@bazel/typescript:index.bzl` * with the loading changes above, `load("@npm//:install_bazel_dependencies.bzl", "install_bazel_dependencies")` is no longer needed in the WORKSPACE which also means that yarn_install does not need to run unless building/testing a target that depends on @npm. In angular/angular this is a minor improvement as almost everything depends on @npm. * @angular/bazel package is also updated in this PR to support the new load location; Angular + Bazel users that require it for ng_package (ng_module is no longer needed in OSS with Angular 10) will need to load from `@npm//@angular/bazel:index.bzl`. I investigated if it was possible to maintain backward compatability for the old load location `@npm_angular_bazel` but it is not since the package itself needs to be updated to load from `@npm//@bazel/typescript:index.bzl` instead of `@npm_bazel_typescript//:index.bzl` as it depends on ts_library internals for ng_module. * runfiles.resolve will now throw instead of returning undefined to match behavior of node require Other changes in angular/angular: * integration/bazel has been updated to use both ng_module and ts_libary with use_angular_plugin=true. The latter is the recommended way for rules_nodejs users to compile Angular 10 with Ivy. Bazel + Angular ViewEngine is supported with @angular/bazel <= 9.0.5 and Angular <= 8. There is still Angular ViewEngine example on rules_nodejs https://github.com/bazelbuild/rules_nodejs/tree/stable/examples/angular_view_engine on these older versions but users that want to update to Angular 10 and are on Bazel must switch to Ivy and at that point ts_library with use_angular_plugin=true is more performant that ng_module. Angular example in rules_nodejs is configured this way as well: https://github.com/bazelbuild/rules_nodejs/tree/stable/examples/angular. As an aside, we also have an example of building Angular 10 with architect() rule directly instead of using ts_library with angular plugin: https://github.com/bazelbuild/rules_nodejs/tree/stable/examples/angular_bazel_architect. NB: ng_module is still required for angular/angular repository as it still builds ViewEngine & @angular/bazel also provides the ng_package rule. ng_module can be removed in the future if ViewEngine is no longer needed in angular repo. * JSModuleInfo provider added to ng_module. this is for forward compat for future rules_nodejs versions. @josephperrott, this touches `packages/bazel/src/external.bzl` which will make the sync to g3 non-trivial. PR Close angular#37727
1 parent f2341e2 commit db56cf1

File tree

63 files changed

+833
-536
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+833
-536
lines changed

.bazelrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ test --test_output=errors
7474
# Trick bazel into treating BUILD files under integration/bazel as being regular files
7575
# This lets us glob() up all the files inside this integration test to make them inputs to tests
7676
# (Note, we cannot use common --deleted_packages because the bazel version command doesn't support it)
77-
build --deleted_packages=integration/bazel,integration/bazel/src,integration/bazel/src/hello-world,integration/bazel/test,integration/bazel/test/e2e
78-
query --deleted_packages=integration/bazel,integration/bazel/src,integration/bazel/src/hello-world,integration/bazel/test,integration/bazel/test/e2e
77+
build --deleted_packages=integration/bazel,integration/bazel/src,integration/bazel/src/hello-world,integration/bazel/test,integration/bazel/tools,integration/bazel/test/e2e
78+
query --deleted_packages=integration/bazel,integration/bazel/src,integration/bazel/src/hello-world,integration/bazel/test,integration/bazel/tools,integration/bazel/test/e2e
7979

8080
################################
8181
# Temporary Settings for Ivy #

.circleci/config.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -862,9 +862,16 @@ workflows:
862862
- build-npm-packages
863863
- build-ivy-npm-packages
864864
- legacy-unit-tests-saucelabs
865-
- components-repo-unit-tests:
866-
requires:
867-
- build-npm-packages
865+
# Temporarily disabled components-repo-unit-tests to update rules_nodejs to 2.0.0. Breaking changes in
866+
# rules_nodejs create a dependency sandwich between angular/angular & angular/components that are very
867+
# difficult and time consuming to resolve and involve patching @angular/bazel in components repo such
868+
# as https://github.com/angular/components/commit/9e7ba251207df77164d73d66620e619bcbc4d2ad. It is simpler to
869+
# 1) land angular/angular upgrade to rule_nodejs 2.0.0 which has breaking changes
870+
# 2) land angular/components upgrade to rules_nodejs 2.0.0 using the @angular/bazel builds snapshot
871+
# 3) update angular/angular to the landed components commit and re-enable these tests
872+
# - components-repo-unit-tests:
873+
# requires:
874+
# - build-npm-packages
868875
- test_zonejs:
869876
requires:
870877
- setup

BUILD.bazel

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,9 @@ filegroup(
4747
"@npm//:node_modules/angular-mocks-1.6/angular-mocks.js",
4848
],
4949
)
50+
51+
# Detect if the build is running under --stamp
52+
config_setting(
53+
name = "stamp",
54+
values = {"stamp": "true"},
55+
)

WORKSPACE

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ 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 = "84abf7ac4234a70924628baa9a73a5a5cbad944c4358cf9abdb4aab29c9a5b77",
12-
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/1.7.0/rules_nodejs-1.7.0.tar.gz"],
11+
sha256 = "4952ef879704ab4ad6729a29007e7094aef213ea79e9f2e94cbe1c9a753e63ef",
12+
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/2.2.0/rules_nodejs-2.2.0.tar.gz"],
1313
)
1414

1515
# Check the rules_nodejs version and download npm dependencies
1616
# Note: bazel (version 2 and after) will check the .bazelversion file so we don't need to
1717
# assert on that.
1818
load("@build_bazel_rules_nodejs//:index.bzl", "check_rules_nodejs_version", "node_repositories", "yarn_install")
1919

20-
check_rules_nodejs_version(minimum_version_string = "1.7.0")
20+
check_rules_nodejs_version(minimum_version_string = "2.2.0")
2121

2222
# Setup the Node.js toolchain
2323
node_repositories(
@@ -39,23 +39,18 @@ yarn_install(
3939
yarn_lock = "//:yarn.lock",
4040
)
4141

42-
# Install all bazel dependencies of the @npm npm packages
43-
load("@npm//:install_bazel_dependencies.bzl", "install_bazel_dependencies")
44-
45-
install_bazel_dependencies()
46-
4742
# Load angular dependencies
4843
load("//packages/bazel:package.bzl", "rules_angular_dev_dependencies")
4944

5045
rules_angular_dev_dependencies()
5146

5247
# Load protractor dependencies
53-
load("@npm_bazel_protractor//:package.bzl", "npm_bazel_protractor_dependencies")
48+
load("@npm//@bazel/protractor:package.bzl", "npm_bazel_protractor_dependencies")
5449

5550
npm_bazel_protractor_dependencies()
5651

5752
# Load karma dependencies
58-
load("@npm_bazel_karma//:package.bzl", "npm_bazel_karma_dependencies")
53+
load("@npm//@bazel/karma:package.bzl", "npm_bazel_karma_dependencies")
5954

6055
npm_bazel_karma_dependencies()
6156

@@ -68,11 +63,6 @@ load("//dev-infra/browsers:browser_repositories.bzl", "browser_repositories")
6863

6964
browser_repositories()
7065

71-
# Setup the rules_typescript tooolchain
72-
load("@npm_bazel_typescript//:index.bzl", "ts_setup_workspace")
73-
74-
ts_setup_workspace()
75-
7666
# Setup the rules_sass toolchain
7767
load("@io_bazel_rules_sass//sass:sass_repositories.bzl", "sass_repositories")
7868

dev-infra/BUILD.bazel

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
load("@build_bazel_rules_nodejs//:index.bzl", "pkg_npm")
2-
load("@npm_bazel_typescript//:index.bzl", "ts_library")
2+
load("@npm//@bazel/typescript:index.bzl", "ts_library")
33

44
ts_library(
55
name = "cli",
@@ -49,15 +49,15 @@ pkg_npm(
4949
# substitutions to replace these in the published version of dev-infra.
5050
"//dev-infra/": "@npm_angular_dev_infra_private//",
5151
"//packages/benchpress": "@npm//@angular/benchpress",
52-
"//packages/bazel/": "@npm_angular_bazel//",
52+
"//packages/bazel": "@npm//@angular/bazel",
5353
"//packages/zone.js/bundles:zone.umd.js": "@npm//:node_modules/zone.js/dist/zone.js",
5454
"//packages/core": "@npm//@angular/core",
5555
"//packages/platform-browser": "@npm//@angular/platform-browser",
5656

5757
# This substitution is particularly verbose because we need to make sure
5858
# that only things available via Angular Bazel are imported from
5959
# tools/defaults.bzl.
60-
"load\(\"//tools:defaults.bzl\", \"ng_module\"\)": "load(\"@npm_angular_bazel//:index.bzl\", \"ng_module\")",
60+
"load\(\"//tools:defaults.bzl\", \"ng_module\"\)": "load(\"@npm//@angular/bazel:index.bzl\", \"ng_module\")",
6161
},
6262
visibility = ["//visibility:public"],
6363
deps = [

dev-infra/benchmark/component_benchmark/benchmark_test.bzl

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

33
"""
44
Macro that can be used to define a benchmark test. This differentiates from

dev-infra/benchmark/component_benchmark/component_benchmark.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
load("//dev-infra/benchmark/ng_rollup_bundle:ng_rollup_bundle.bzl", "ng_rollup_bundle")
22
load("//tools:defaults.bzl", "ng_module")
3-
load("@npm_bazel_typescript//:index.bzl", "ts_devserver", "ts_library")
3+
load("@npm//@bazel/typescript:index.bzl", "ts_devserver", "ts_library")
44
load(":benchmark_test.bzl", "benchmark_test")
55

66
def copy_default_file(origin, destination):

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

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

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

55
ts_library(
66
name = "driver-utilities",

dev-infra/benchmark/ng_rollup_bundle/ng_rollup_bundle.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
# found in the LICENSE file at https://angular.io/license
55

66
load("@build_bazel_rules_nodejs//:index.bzl", "npm_package_bin")
7-
load("@npm_bazel_terser//:index.bzl", "terser_minified")
8-
load("@npm_bazel_rollup//:index.bzl", "rollup_bundle")
7+
load("@npm//@bazel/terser:index.bzl", "terser_minified")
8+
load("@npm//@bazel/rollup:index.bzl", "rollup_bundle")
99
load("//dev-infra/bazel:expand_template.bzl", "expand_template")
1010

1111
def ng_rollup_bundle(

dev-infra/caretaker/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/typescript:index.bzl", "ts_library")
22

33
ts_library(
44
name = "caretaker",

0 commit comments

Comments
 (0)