You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Migrate to Angular's app_bundle for bundling. (#6049)
The upcoming upgrade to Angular 13+ introduces a number of
bundling-related problems for our tests and applications. Angular has
developed some internal tooling to help resolve these problems. This
change uses Angular's internal app_bundle() macro to allow us to
continue to bundle Angular13+-compatible apps.
Note: app_bundle() is Angular-internal and not supported for external
use. We use it at our own risk. Googlers, see the following documents
for background and justification: http://go/angular-bazel-problems,
http://go/tb-oss-bundling.
Note: We migrated our tests to use the similar spec_bundle() in
#6036.
Our usage of app_bundle() is largely guided/inspired by the usage in the
angular/components repo. This is the version at HEAD as of early
November:
https://github.com/angular/components/blob/871f8f231a7a86a7a0778e345f4d517109c9a357/tools/defaults.bzl
We will now have two bundling targets: tf_js_binary(), which remains
unchanged; and tf_ng_prod_js_binary(), which is new and delegates to
app_bundle(). tf_ng_prod_js_binary() is, in practice, only used for one
bundle: The production Angular bundle at
//tensorboard/webapp:tb_webapp_binary.
All other bundles, including our dev Angular bundle, continue to use
tf_js_binary().
Googlers, see detailed reasoning in http://go/tb-oss-bundling.
Highlights.
1. Run the following commands to install additional Angular build
tooling and terser and then clean the environment:
* `yarn add @angular-devkit/[email protected]
@bazel/[email protected] --dev`
* `yarn run yarn-deduplicate`
* `rm -rf node_modules; bazel clean --expunge; yarn;`
2. Patch the Angular build tooling to suit our code base:
* Patch the esbuild config to point to old paths for tools in
@angular/compiler-cli. When we upgrade @angular/compiler-cli to Angular
13+ then we will be able to delete this portion of the patch.
* Patch some of the babel-based optimization code to remove one
particular plugin that is too aggressive in removing symbols. It is
incompatible with the TensorBoard code base.
3. Add tf_ng_prod_js_binary, which delegates to app_bundle(), and use it
for //tensorboard/webapp:tb_webapp_binary.
Impact on "//tensorboard" build:
* "//tensorboard/webapp:tb_webapp_binary" bundle size:
* Before: 5,440,612 bytes
* After: 4,790,003
* "//tensorboard/webapp:tb_webapp_binary" bundle time:
* Before: 1 or 2 seconds.
* After: ~20 seconds.
* This is an ok tradeoff since we continue to encourage engineers to use
the faster "//tensorboard:dev" and its dev bundle for local development.
Impact on "//tensorboard:dev" target:
* No impact on either bundle size or bundle time since we continue to
use tf_js_binary(). It remains big but fast.
* Note that when we update to Angular 13 we will have to change
"//tensorboard:dev" to use Angular JIT compilation. Initial observations
show that the JIT compilation does not meaningfully slow down app load
or interaction times.
0 commit comments