From 00d801122cae8129d6532b73138aed171ab55a3a Mon Sep 17 00:00:00 2001 From: Joey Perrott Date: Fri, 15 Oct 2021 13:22:30 -0700 Subject: [PATCH] build: Use Ivy compiler for bazel builds by default (#43862) Setting the angular_ivy_enabled environment variable to True will default Bazel builds to use the Ivy compiler rather than defaulting to ViewEngine. PR Close #43862 --- .bazelrc | 5 ++--- .circleci/config.yml | 12 ++++++------ .vscode/recommended-launch.json | 3 --- .vscode/recommended-tasks.json | 4 ---- docs/BAZEL.md | 8 ++------ docs/DEBUG_COMPONENTS_REPO_IVY.md | 2 +- packages/core/src/render3/util/global_utils.ts | 3 +-- packages/core/test/bundling/README.md | 12 ++++++------ packages/core/test/bundling/core_all/BUILD.bazel | 3 --- packages/core/test/render3/perf/README.md | 8 ++++---- packages/core/test/render3/perf/profile_all.js | 2 +- .../core/test/render3/perf/profile_in_browser.html | 3 +-- scripts/build/angular-in-memory-web-api.js | 2 +- scripts/build/package-builder.js | 3 +-- tools/saucelabs/README.md | 8 +++----- .../run_all_symbols_extractor_tests.js | 3 +-- 16 files changed, 30 insertions(+), 51 deletions(-) diff --git a/.bazelrc b/.bazelrc index d0f63e8c11a5d..c282e5e682874 100644 --- a/.bazelrc +++ b/.bazelrc @@ -84,9 +84,8 @@ query --deleted_packages=integration/bazel,integration/bazel/src,integration/baz ################################ # Temporary Settings for Ivy # ################################ -# To determine if the compiler used should be Ivy instead of ViewEngine, one can use `--config=ivy` -# on any bazel target. This is a temporary flag until codebase is permanently switched to Ivy. -build --define=angular_ivy_enabled=False +# Set the default compiler used for bazel builds to be Ivy. +build --define=angular_ivy_enabled=True build:view-engine --define=angular_ivy_enabled=False build:ivy --define=angular_ivy_enabled=True diff --git a/.circleci/config.yml b/.circleci/config.yml index b6801372e3a02..8b0381fad81fa 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -358,7 +358,7 @@ jobs: command: | yarn bazel run //tools/saucelabs:sauce_service_setup TESTS=$(./node_modules/.bin/bazelisk query --output label '(kind(karma_web_test, ...) intersect attr("tags", "saucelabs", ...)) except attr("tags", "ivy-only", ...) except attr("tags", "fixme-saucelabs-ve", ...)') - yarn bazel test --config=saucelabs ${TESTS} + yarn bazel test --config=saucelabs --config=view-engine ${TESTS} yarn bazel run //tools/saucelabs:sauce_service_stop no_output_timeout: 40m - notify_webhook_on_fail: @@ -382,7 +382,7 @@ jobs: command: | yarn bazel run //tools/saucelabs:sauce_service_setup TESTS=$(./node_modules/.bin/bazelisk query --output label '(kind(karma_web_test, ...) intersect attr("tags", "saucelabs", ...)) except attr("tags", "no-ivy-aot", ...) except attr("tags", "fixme-saucelabs-ivy", ...)') - yarn bazel test --config=saucelabs --config=ivy ${TESTS} + yarn bazel test --config=saucelabs ${TESTS} yarn bazel run //tools/saucelabs:sauce_service_stop no_output_timeout: 40m - notify_webhook_on_fail: @@ -776,11 +776,11 @@ jobs: - setup_win - run: name: Build all windows CI targets - command: bazel build --build_tag_filters=-ivy-only //packages/compiler-cli/... + command: bazel build --config=view-engine --build_tag_filters=-ivy-only //packages/compiler-cli/... no_output_timeout: 15m - run: name: Test all windows CI targets - command: bazel test --test_tag_filters="-ivy-only,-browser:chromium-local" //packages/compiler-cli/... + command: bazel test --config=view-engine --test_tag_filters="-ivy-only,-browser:chromium-local" //packages/compiler-cli/... no_output_timeout: 15m test_ivy_aot_win: @@ -789,11 +789,11 @@ jobs: - setup_win - run: name: Build all windows CI targets - command: bazel build --config=ivy --build_tag_filters=-no-ivy-aot,-fixme-ivy-aot //packages/compiler-cli/... + command: bazel build --build_tag_filters=-no-ivy-aot,-fixme-ivy-aot //packages/compiler-cli/... no_output_timeout: 15m - run: name: Test all windows CI targets - command: bazel test --config=ivy --test_tag_filters="-no-ivy-aot,-fixme-ivy-aot,-browser:chromium-local" //packages/compiler-cli/... //packages/localize/... + command: bazel test --test_tag_filters="-no-ivy-aot,-fixme-ivy-aot,-browser:chromium-local" //packages/compiler-cli/... //packages/localize/... no_output_timeout: 15m # Save dependencies to use on subsequent runs. - save_cache: diff --git a/.vscode/recommended-launch.json b/.vscode/recommended-launch.json index 9b08e7c762d50..2413645f41cb8 100644 --- a/.vscode/recommended-launch.json +++ b/.vscode/recommended-launch.json @@ -39,7 +39,6 @@ "program": "${workspaceFolder}/node_modules/.bin/bazelisk", "args": [ "test", - "--config=ivy", "packages/core/test/acceptance", "--config=debug" ], @@ -57,7 +56,6 @@ "program": "${workspaceFolder}/node_modules/.bin/bazelisk", "args": [ "test", - "--config=ivy", "packages/core/test/render3", "--config=debug" ], @@ -75,7 +73,6 @@ "program": "${workspaceFolder}/node_modules/.bin/bazelisk", "args": [ "test", - "--config=ivy", "packages/core/test", "--config=debug" ], diff --git a/.vscode/recommended-tasks.json b/.vscode/recommended-tasks.json index 0bd05ff37cbea..5f33ac12f9815 100644 --- a/.vscode/recommended-tasks.json +++ b/.vscode/recommended-tasks.json @@ -9,7 +9,6 @@ "command": "${workspaceFolder}/node_modules/.bin/bazelisk", "args": [ "test", - "--config=ivy", "packages/core/test", "packages/core/test/acceptance", "packages/core/test/render3", @@ -42,7 +41,6 @@ "command": "${workspaceFolder}/node_modules/.bin/bazelisk", "args": [ "test", - "--config=ivy", "packages/core/test/acceptance", ], "group": "test", @@ -71,7 +69,6 @@ "command": "${workspaceFolder}/node_modules/.bin/bazelisk", "args": [ "test", - "--config=ivy", "packages/core/test", ], "group": "test", @@ -100,7 +97,6 @@ "command": "${workspaceFolder}/node_modules/.bin/bazelisk", "args": [ "test", - "--config=ivy", "packages/core/test/render3", ], "group": "test", diff --git a/docs/BAZEL.md b/docs/BAZEL.md index 06f573e248b4c..0e47a27f3f9a3 100644 --- a/docs/BAZEL.md +++ b/docs/BAZEL.md @@ -63,12 +63,8 @@ See also: [`//.bazelrc`](https://github.com/angular/angular/blob/master/.bazelrc - `--config=debug`: build and launch in debug mode (see [debugging](#debugging) instructions below) - `--test_arg=--node_options=--inspect=9228`: change the inspector port. -- `--config=ivy` Enables ivy mode if present, otherwise ViewEngine is used. This switches which compiler is used (ngc or ngtsc) -- `--config=view-engine` Enables ViewEngine mode if present, currently this the default mode. This switches which compiler is used (ngc or ngtsc) +- `--config=view-engine` Enables ViewEngine mode if present, otherwise Ivy is used. This switches which compiler is used (ngc or ngtsc) - `--test_tag_filters=`: filter tests down to tags defined in the `tag` config of your rules in any given `BUILD.bazel`. - - `no-ivy-aot`: Useful for excluding build and test targets that are not meant to be executed in Ivy AOT mode (`--config=ivy`). - - `ivy-only`: Useful for excluding all Ivy build and tests targets with `--config=view-engine`. - - `fixme-ivy-aot`: Useful for including/excluding build and test targets that are currently broken in Ivy AOT mode (`--config=ivy`). ### Debugging a Node Test @@ -276,7 +272,7 @@ Require stack: `bazel run` only works in Bazel Windows with non-test targets. Ensure that you are using `bazel test` instead. -e.g: `yarn bazel test packages/core/test/bundling/forms:symbol_test --config=ivy` +e.g: `yarn bazel test packages/core/test/bundling/forms:symbol_test` #### mkdir missing If you see the following error:: diff --git a/docs/DEBUG_COMPONENTS_REPO_IVY.md b/docs/DEBUG_COMPONENTS_REPO_IVY.md index ddad1a598d810..079b7a9c5722b 100644 --- a/docs/DEBUG_COMPONENTS_REPO_IVY.md +++ b/docs/DEBUG_COMPONENTS_REPO_IVY.md @@ -20,7 +20,7 @@ node ./scripts/ci/update-framework-deps-to-dist-packages.js {COMPONENTS_REPO}/pa following command: ```bash -yarn test --deleted_packages=//src/dev-app --config=ivy +yarn test --deleted_packages=//src/dev-app ``` ### Running tests for individual entry-points diff --git a/packages/core/src/render3/util/global_utils.ts b/packages/core/src/render3/util/global_utils.ts index ad886077919c9..c35ecb7fb647b 100644 --- a/packages/core/src/render3/util/global_utils.ts +++ b/packages/core/src/render3/util/global_utils.ts @@ -19,8 +19,7 @@ import {getComponent, getContext, getDirectiveMetadata, getDirectives, getHostEl * * To see this in action run the following command: * - * bazel run --config=ivy - * //packages/core/test/bundling/todo:devserver + * bazel run //packages/core/test/bundling/todo:devserver * * Then load `localhost:5432` and start using the console tools. */ diff --git a/packages/core/test/bundling/README.md b/packages/core/test/bundling/README.md index 80ea46be31362..2b5d31f020d3c 100644 --- a/packages/core/test/bundling/README.md +++ b/packages/core/test/bundling/README.md @@ -6,12 +6,12 @@ This is asserted by keeping gold files of all symbols which are expected to be r When doing renaming it is often necessary to update the gold files, to do so use these commands: ``` -yarn bazel run --config=ivy //packages/core/test/bundling/injection:symbol_test.accept -yarn bazel run --config=ivy //packages/core/test/bundling/cyclic_import:symbol_test.accept -yarn bazel run --config=ivy //packages/core/test/bundling/forms:symbol_test.accept -yarn bazel run --config=ivy //packages/core/test/bundling/hello_world:symbol_test.accept -yarn bazel run --config=ivy //packages/core/test/bundling/router:symbol_test.accept -yarn bazel run --config=ivy //packages/core/test/bundling/todo:symbol_test.accept +yarn bazel run //packages/core/test/bundling/injection:symbol_test.accept +yarn bazel run //packages/core/test/bundling/cyclic_import:symbol_test.accept +yarn bazel run //packages/core/test/bundling/forms:symbol_test.accept +yarn bazel run //packages/core/test/bundling/hello_world:symbol_test.accept +yarn bazel run //packages/core/test/bundling/router:symbol_test.accept +yarn bazel run //packages/core/test/bundling/todo:symbol_test.accept ``` ## Running all symbol tests diff --git a/packages/core/test/bundling/core_all/BUILD.bazel b/packages/core/test/bundling/core_all/BUILD.bazel index f6ac54dbe711c..7803c32a7857f 100644 --- a/packages/core/test/bundling/core_all/BUILD.bazel +++ b/packages/core/test/bundling/core_all/BUILD.bazel @@ -28,9 +28,6 @@ ng_rollup_bundle( js_size_tracking_test( name = "size_test", src = "angular/packages/core/test/bundling/core_all/bundle.min.js", - # Ensures that this target runs with "--config=ivy" (aka Ivy). This is necessary - # because we don't run this test on CI currently, but if we run it manually, we need to - # ensure that it runs with Ivy for proper size comparisons. angular_ivy_enabled = "True", data = [ "bundle.golden_size_map_ivy.json", diff --git a/packages/core/test/render3/perf/README.md b/packages/core/test/render3/perf/README.md index 781d0d58fdc73..032bcaf0dfad9 100644 --- a/packages/core/test/render3/perf/README.md +++ b/packages/core/test/render3/perf/README.md @@ -1,7 +1,7 @@ ### Build ``` -yarn bazel build //packages/core/test/render3/perf:${BENCHMARK}_lib.min_debug.js --config=ivy +yarn bazel build //packages/core/test/render3/perf:${BENCHMARK}_lib.min_debug.js ``` ### Run @@ -72,15 +72,15 @@ The resulting output should look something like this: ### Notes To run the benchmark use `bazel run `, example: -- `yarn bazel run --config=ivy //packages/core/test/render3/perf:noop_change_detection` +- `yarn bazel run //packages/core/test/render3/perf:noop_change_detection` To profile, append `_profile` to the target name and attach a debugger via chrome://inspect, example: -- `yarn bazel run --config=ivy //packages/core/test/render3/perf:noop_change_detection_profile` +- `yarn bazel run //packages/core/test/render3/perf:noop_change_detection_profile` To interactively edit/rerun benchmarks use `ibazel` instead of `bazel`. To debug - Follow the directions in `profile_in_browser.html` OR -- `yarn bazel build --config=ivy //packages/core/test/render3/perf:noop_change_detection` +- `yarn bazel build //packages/core/test/render3/perf:noop_change_detection` - `node --inspect-brk bazel-out/darwin-fastbuild/bin/packages/core/test/render3/perf/noop_change_detection.min_debug.js` diff --git a/packages/core/test/render3/perf/profile_all.js b/packages/core/test/render3/perf/profile_all.js index cf4dec42a35c0..c807e261eb93d 100644 --- a/packages/core/test/render3/perf/profile_all.js +++ b/packages/core/test/render3/perf/profile_all.js @@ -29,7 +29,7 @@ const profileTests = // build tests shell.exec( - `yarn bazel build --config=ivy ` + + `yarn bazel build ` + profileTests.map((name) => `//packages/core/test/render3/perf:${name}_lib.min_debug.js`) .join(' ')); diff --git a/packages/core/test/render3/perf/profile_in_browser.html b/packages/core/test/render3/perf/profile_in_browser.html index 58c21e9e2225a..ad715df9fab1b 100644 --- a/packages/core/test/render3/perf/profile_in_browser.html +++ b/packages/core/test/render3/perf/profile_in_browser.html @@ -9,8 +9,7 @@
    -
  1. Build the benchmark using yarn bazel build //packages/core/test/render3/perf:${BENCHMARK}.min_debug.js - --config=ivy
  2. +
  3. Build the benchmark using yarn bazel build //packages/core/test/render3/perf:${BENCHMARK}.min_debug.js
  4. Open this file using the file:// protocol and add ?benchmark=BENCHMARK to the URL.
  5. Note: You should likely run this in an incognito browser with the "no-turbo-inlining" flag.
    diff --git a/scripts/build/angular-in-memory-web-api.js b/scripts/build/angular-in-memory-web-api.js index 323da56ef33a6..0e8ac2ddb4a5a 100644 --- a/scripts/build/angular-in-memory-web-api.js +++ b/scripts/build/angular-in-memory-web-api.js @@ -34,7 +34,7 @@ function buildAngularInMemoryWebApiPackage(destDir) { console.info(`${scriptPath}:`); console.info(' Building angular-in-memory-web-api npm package'); console.info('##############################'); - exec(`${bazelCmd} build //packages/misc/angular-in-memory-web-api:npm_package --config=ivy`); + exec(`${bazelCmd} build //packages/misc/angular-in-memory-web-api:npm_package`); // Create the output directory. const absDestDir = resolve(baseDir, destDir); diff --git a/scripts/build/package-builder.js b/scripts/build/package-builder.js index 475ed64ca6fd6..a9288f6a1fdb2 100644 --- a/scripts/build/package-builder.js +++ b/scripts/build/package-builder.js @@ -92,8 +92,7 @@ function buildTargetPackages(destDir, description, isRelease = false) { // Use either `--config=snapshot` or `--config=release` so that builds are created with the // correct embedded version info. - exec(`${bazelCmd} build --config=${isRelease ? 'release' : 'snapshot'} --config=ivy ${ - targets.join(' ')}`); + exec(`${bazelCmd} build --config=${isRelease ? 'release' : 'snapshot'} ${targets.join(' ')}`); // Create the output directory. const absDestDir = resolve(baseDir, destDir); diff --git a/tools/saucelabs/README.md b/tools/saucelabs/README.md index 144ce01183ade..dbce0c4e53c4f 100644 --- a/tools/saucelabs/README.md +++ b/tools/saucelabs/README.md @@ -29,11 +29,9 @@ yarn bazel run //tools/saucelabs:sauce_service_setup For example, `packages/core/test:test_web` becomes `packages/core/test:saucelabs_test_web`. ``` -yarn bazel test //packages/core/test:saucelabs_test_web --config=saucelabs --config=ivy +yarn bazel test //packages/core/test:saucelabs_test_web --config=saucelabs ``` -Remove the `--config=ivy` if you want to run through View Engine instead. - 5. Sauce service log may be tailed or dumped with the following targets: ``` bash @@ -54,7 +52,7 @@ Running all ViewEngine karma tests in Saucelabs: ``` bash yarn bazel run //tools/saucelabs:sauce_service_setup TESTS=$(./node_modules/.bin/bazelisk query --output label '(kind(karma_web_test, ...) intersect attr("tags", "saucelabs", ...)) except attr("tags", "ivy-only", ...) except attr("tags", "fixme-saucelabs-ve", ...)') -yarn bazel test --config=saucelabs ${TESTS} +yarn bazel test --config=saucelabs --config=view-engine ${TESTS} ``` Running all Ivy karma tests in Saucelabs: @@ -62,7 +60,7 @@ Running all Ivy karma tests in Saucelabs: ``` bash yarn bazel run //tools/saucelabs:sauce_service_setup TESTS=$(./node_modules/.bin/bazelisk query --output label '(kind(karma_web_test, ...) intersect attr("tags", "saucelabs", ...)) except attr("tags", "no-ivy-aot", ...) except attr("tags", "fixme-saucelabs-ivy", ...)') -yarn bazel test --config=saucelabs --config=ivy ${TESTS} +yarn bazel test --config=saucelabs ${TESTS} ``` ## Under the hood diff --git a/tools/symbol-extractor/run_all_symbols_extractor_tests.js b/tools/symbol-extractor/run_all_symbols_extractor_tests.js index c438d271c0269..1410c31de6b19 100644 --- a/tools/symbol-extractor/run_all_symbols_extractor_tests.js +++ b/tools/symbol-extractor/run_all_symbols_extractor_tests.js @@ -39,8 +39,7 @@ const ALL_ACCEPT_TARGETS = ALL_TEST_TARGETS.map(test => `${test}.accept`); function runBazelCommandOnTargets(command, targets, present) { for (const target of targets) { process.stdout.write(`${present}: ${target}`); - const commandResult = - spawnSync('yarn', ['-s', 'bazel', command, '--config=ivy', target], {encoding: 'utf8'}); + const commandResult = spawnSync('yarn', ['-s', 'bazel', command, target], {encoding: 'utf8'}); process.stdout.clearLine(); process.stdout.cursorTo(0); if (commandResult.status) {