Skip to content

Commit 4ab4fa5

Browse files
zzzariescopybara-github
authored andcommitted
Upgrade angular from v12 to v14
Few changes: - upgrade rules_nodejs to 5.7.0 (this will extend the nodejs versions available for installation, while we are installing the default nodejs version here with the 5.7.0 rules_nodejs toolchain) - following this, upgrade all bazel toolchain to 5..7.0 - correspondingly upgrade rules_sass version to 1.55.0 (I can only find rules_sass github codebase with given version tag, but not sure how to find its hash..etc. Here we are basically following tensorboard team's current setup) - upgrade angular (and all relative packages) to v14, correspondingly upgrade ngrx to v14, and bump up rxjs. - upgrade typescript to 4.7.4 - upgrade zone.js to 0.12.0 - import ts_library (used for bazel build) from concatjs instead of typescript, as the module is moved to concatjs. (Also added concatjs into data field of `tsc_wrapped_with_angular` target) - added name field to the output of `rollup.config.js`, as it is a required field now for iife output type - Added `node_modules` into `include_paths` of sass_binary build rule when building the `styles.css` file for frontend. This is because angular v14 changed to import angular/cdk from using a relative path to an new one like `@angular/cdk`, so we need to include the `node_modules` int the the searching paths to enable sassCompiler to find the theming file. - yarn_install's exports_directories_only property now defaults to True. We must set this to False in order to remain compatible with ts_library See: https://github.com/bazelbuild/rules_nodejs/wiki/Migrating-to-5.0#exports_directories_only - No longer need to override node_version as rules_nodejs default version of node is now 16.12.0. See: https://github.com/bazelbuild/rules_nodejs/wiki/Migrating-to-5.0#updated-defaults We were overriding this only because rules_nodejs defaul version of node was too old. **References** - migrating to rules_nodejs 5.0: https://github.com/bazelbuild/rules_nodejs/wiki/Migrating-to-5.0 - Instructions for 5.7.0 specifically: https://github.com/bazelbuild/rules_nodejs/releases/tag/5.7.0 - Tensorboard team's angular upgrade notes: No longer need to override node_version as rules_nodejs default version of node is now 16.12.0. See: https://github.com/bazelbuild/rules_nodejs/wiki/Migrating-to-5.0#updated-defaults We were overriding this only because rules_nodejs defaul version of node was too old. - other relative tensorboard upgrade PRs (tons of information in the PR messasge): tensorflow/tensorboard#5977 tensorflow/tensorboard#6063 tensorflow/tensorboard#6066 **Notes** Since then, the tensorboard_plugin_profiler build process mostly follows tensorboard's setup, but we are diverging moving forward as following: (1) The tensorboard team changed to use esbuild to bundle the js file instead of rollup (see tensorflow/tensorboard#5829). We may consider switching to esbuild in the future as well given its potential better performance, but now since it's not blocking us, we remain to use rollup. (2) The tensorboard team uses angular teams internal toolchain to build angular with bazel for angular v13+ (see tensorflow/tensorboard#6049). Since we turns out don't have the issue tensorboard is facing when upgrading angular, we are fine to go forward without changing our bundling rules. And we tend not to because the toolchain is not publicly used and there's no guarantee on supporting in the future. PiperOrigin-RevId: 537957341
1 parent 53defad commit 4ab4fa5

File tree

7 files changed

+644
-516
lines changed

7 files changed

+644
-516
lines changed

WORKSPACE

+20-16
Original file line numberDiff line numberDiff line change
@@ -67,36 +67,40 @@ rules_closure_dependencies(
6767

6868
http_archive(
6969
name = "build_bazel_rules_nodejs",
70-
sha256 = "d63ecec7192394f5cc4ad95a115f8a6c9de55c60d56c1f08da79c306355e4654",
70+
sha256 = "c29944ba9b0b430aadcaf3bf2570fece6fc5ebfb76df145c6cdad40d65c20811",
7171
urls = [
72-
"http://mirror.tensorflow.org/github.com/bazelbuild/rules_nodejs/releases/download/4.6.1/rules_nodejs-4.6.1.tar.gz",
73-
"https://github.com/bazelbuild/rules_nodejs/releases/download/4.6.1/rules_nodejs-4.6.1.tar.gz",
72+
"http://mirror.tensorflow.org/github.com/bazelbuild/rules_nodejs/releases/download/5.7.0/rules_nodejs-5.7.0.tar.gz",
73+
"https://github.com/bazelbuild/rules_nodejs/releases/download/5.7.0/rules_nodejs-5.7.0.tar.gz",
7474
],
7575
)
7676

77-
load("@build_bazel_rules_nodejs//:index.bzl", "node_repositories", "yarn_install")
78-
node_repositories(
79-
node_version = "12.21.0",
80-
)
77+
load("@build_bazel_rules_nodejs//:repositories.bzl", "build_bazel_rules_nodejs_dependencies")
78+
build_bazel_rules_nodejs_dependencies()
79+
load("@build_bazel_rules_nodejs//:index.bzl", "yarn_install")
8180

8281
yarn_install(
8382
name = "npm",
83+
# "Some rules only work by referencing labels nested inside npm packages
84+
# and therefore require turning off exports_directories_only."
85+
# This includes "ts_library".
86+
# See: https://github.com/bazelbuild/rules_nodejs/wiki/Migrating-to-5.0#exports_directories_only
87+
exports_directories_only = False,
8488
package_json = "//:package.json",
8589
yarn_lock = "//:yarn.lock",
86-
# Opt out of symlinking local node_modules folder into bazel internal
87-
# directory. Symlinking is incompatible with our toolchain which often
88-
# removes source directory without `bazel clean` which creates broken
89-
# symlink into node_modules folder.
90-
symlink_node_modules = False,
9190
)
9291

92+
# rules_sass release information is difficult to find but it does seem to
93+
# regularly release with same cadence and version as core sass.
94+
# We typically upgrade this library whenever we upgrade rules_nodejs.
95+
#
96+
# rules_sass 1.55.0: https://github.com/bazelbuild/rules_sass/tree/1.55.0
9397
http_archive(
9498
name = "io_bazel_rules_sass",
95-
sha256 = "ee6d527550d42af182673c3718da98bb9205cabdeb08eacc0e3767fa3f2b051a",
96-
strip_prefix = "rules_sass-1.49.11",
99+
sha256 = "1ea0103fa6adcb7d43ff26373b5082efe1d4b2e09c4f34f8a8f8b351e9a8a9b0",
100+
strip_prefix = "rules_sass-1.55.0",
97101
urls = [
98-
"http://mirror.tensorflow.org/github.com/bazelbuild/rules_sass/archive/1.49.11.zip",
99-
"https://github.com/bazelbuild/rules_sass/archive/1.49.11.zip",
102+
"http://mirror.tensorflow.org/github.com/bazelbuild/rules_sass/archive/1.55.0.zip",
103+
"https://github.com/bazelbuild/rules_sass/archive/1.55.0.zip",
100104
],
101105
)
102106

defs/BUILD.bazel

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ nodejs_binary(
66
name = "tsc_wrapped_with_angular",
77
data = [
88
"@npm//@angular/compiler-cli",
9+
"@npm//@bazel/concatjs",
910
"@npm//@bazel/typescript",
1011
],
11-
entry_point = "@npm//:node_modules/@bazel/typescript/internal/tsc_wrapped/tsc_wrapped.js",
12+
entry_point = "@npm//:node_modules/@bazel/concatjs/internal/tsc_wrapped/tsc_wrapped.js",
1213
visibility = ["//:__subpackages__"],
1314
)

defs/defs.bzl

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
"""External-only delegates for various BUILD rules."""
1616

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

1919
def _convert_paths_to_absolute_impl(ctx):
2020
"""Implementation of convert_paths_to_absolute.

frontend/BUILD

+6
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ sass_library(
7373
sass_binary(
7474
name = "css",
7575
src = "styles.scss",
76+
# @use was very different in angular v13.x using a relative path @use '../../../cdk/a11y'
77+
# instead to the new one in v14.x @use '@angular/cdk'
78+
# need to include the node_modules path to enable sass to find the theming file
79+
include_paths = [
80+
"node_modules",
81+
],
7682
output_name = "styles.css",
7783
sourcemap = False,
7884
deps = [

package.json

+24-24
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,25 @@
2828
},
2929
"homepage": "https://github.com/tensorflow/profiler#readme",
3030
"devDependencies": {
31-
"@angular/cli": "^12.2.0",
32-
"@angular/compiler": "^12.2.0",
33-
"@angular/compiler-cli": "^12.2.0",
31+
"@angular/cli": "^14.2.9",
32+
"@angular/compiler": "^14.2.11",
33+
"@angular/compiler-cli": "^14.2.11",
3434
"@bazel/bazelisk": "^1.7.5",
3535
"@bazel/ibazel": "^0.15.9",
36-
"@bazel/jasmine": "^4.6.1",
37-
"@bazel/concatjs": "^4.6.1",
38-
"@bazel/rollup": "^4.6.1",
39-
"@bazel/typescript": "^4.6.1",
36+
"@bazel/jasmine": "^5.7.0",
37+
"@bazel/concatjs": "^5.7.0",
38+
"@bazel/rollup": "^5.7.0",
39+
"@bazel/typescript": "^5.7.0",
4040
"@types/chai": "^4.2.7",
4141
"@types/google.visualization": "0.0.65",
4242
"@types/jasmine": "^3.5.0",
4343
"@types/node": "^13.1.2",
4444
"@types/sinon": "^7.5.1",
45-
"tslib": "^2.0.1",
45+
"tslib": "^2.3.6",
4646
"chai": "^4.2.0",
4747
"prettier": "1.18.2",
4848
"sinon": "^7.4.2",
49-
"typescript": "4.3.5",
49+
"typescript": "4.7.4",
5050
"rollup": "^2.56.2",
5151
"@rollup/plugin-commonjs": "^20.0.0",
5252
"@rollup/plugin-node-resolve": "^13.0.4",
@@ -64,22 +64,22 @@
6464
"terser": "^5.6.0"
6565
},
6666
"dependencies": {
67-
"@angular/animations": "^12.2.0",
68-
"@angular/cdk": "^12.2.0",
69-
"@angular/common": "^12.2.0",
70-
"@angular/core": "^12.2.0",
71-
"@angular/forms": "^12.2.0",
72-
"@angular/localize": "^12.2.0",
73-
"@angular/material": "^12.2.3",
74-
"@angular/platform-browser": "^12.2.0",
75-
"@angular/platform-browser-dynamic": "^12.2.0",
76-
"@angular/router": "^12.2.0",
77-
"@ngrx/effects": "^12.3.0",
78-
"@ngrx/store": "^12.3.0",
67+
"@angular/animations": "^14.2.11",
68+
"@angular/cdk": "^14.2.7",
69+
"@angular/common": "^14.2.11",
70+
"@angular/core": "^14.2.11",
71+
"@angular/forms": "^14.2.11",
72+
"@angular/localize": "^14.2.11",
73+
"@angular/material": "^14.2.7",
74+
"@angular/platform-browser": "^14.2.11",
75+
"@angular/platform-browser-dynamic": "^14.2.11",
76+
"@angular/router": "^14.2.11",
77+
"@ngrx/effects": "^14.3.2",
78+
"@ngrx/store": "^14.3.2",
7979
"@polymer/polymer": "^3.4.1",
80-
"tslib": "^2.0.1",
81-
"rxjs": "^7.3.0",
82-
"zone.js": "^0.11.4"
80+
"tslib": "^2.3.6",
81+
"rxjs": "^7.5.7",
82+
"zone.js": "^0.12.0"
8383
},
8484
"overrides": {
8585
"minimist" : "1.2.6",

rollup.config.js

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ module.exports = {
99
commonjs(),
1010
],
1111
output: {
12+
// Name field is required for iife|umd file format
13+
name: 'tbp',
1214
strict: false,
1315
format: 'iife',
1416
sourcemap: false,

0 commit comments

Comments
 (0)