Skip to content

Commit 807c894

Browse files
josephperrottmatsko
authored andcommitted
build: migrate determining if Ivy is enabled in typescript genrule files to use angular_ivy_enabled (angular#33983)
Use angular_ivy_enabled to determine if Ivy is being used for the ivy_test_selector.ts symbols. Additionally, remove the reflect_metadata genrules as we not longer have a "jit" compile option so all possible invocations result in the same generated file. Instead we can just commit this file. PR Close angular#33983
1 parent 4022376 commit 807c894

File tree

9 files changed

+24
-62
lines changed

9 files changed

+24
-62
lines changed

packages/core/test/bundling/core_all/BUILD.bazel

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ ng_rollup_bundle(
2828
js_size_tracking_test(
2929
name = "size_test",
3030
src = "angular/packages/core/test/bundling/core_all/bundle.min.js",
31+
# Ensures that this target runs with "--config=ivy" (aka Ivy). This is necessary
32+
# because we don't run this test on CI currently, but if we run it manually, we need to
33+
# ensure that it runs with Ivy for proper size comparisons.
34+
angular_ivy_enabled = "True",
3135
data = [
3236
"bundle.golden_size_map_ivy.json",
3337
":bundle",
3438
],
3539
golden_file = "angular/packages/core/test/bundling/core_all/bundle.golden_size_map_ivy.json",
3640
max_byte_diff = 250,
3741
max_percentage_diff = 15,
38-
# Ensures that this target runs with "--define=compile=aot" (aka Ivy). This is necessary
39-
# because we don't run this test on CI currently, but if we run it manually, we need to
40-
# ensure that it runs with Ivy for proper size comparisons.
41-
required_compile_mode = "aot",
4242
source_map = "angular/packages/core/test/bundling/core_all/bundle.min.js.map",
4343
tags = [
4444
"ivy-only",
@@ -49,17 +49,17 @@ js_size_tracking_test(
4949
js_size_tracking_test(
5050
name = "size_test_view_engine",
5151
src = "angular/packages/core/test/bundling/core_all/bundle.min.js",
52+
# Ensures that this target runs with `--config=view-engine`. This is
53+
# necessary because we don't run this test on CI currently, but if we run it manually,
54+
# we need to ensure that it runs with View Engine for proper size comparisons.
55+
angular_ivy_enabled = "False",
5256
data = [
5357
"bundle.golden_size_map_view_engine.json",
5458
":bundle",
5559
],
5660
golden_file = "angular/packages/core/test/bundling/core_all/bundle.golden_size_map_view_engine.json",
5761
max_byte_diff = 250,
5862
max_percentage_diff = 15,
59-
# Ensures that this target runs with "--define=compile=legacy" (View Engine). This is
60-
# necessary because we don't run this test on CI currently, but if we run it manually,
61-
# we need to ensure that it runs with View Engine for proper size comparisons.
62-
required_compile_mode = "legacy",
6363
source_map = "angular/packages/core/test/bundling/core_all/bundle.min.js.map",
6464
tags = [
6565
"manual",

packages/core/test/bundling/util/BUILD.bazel

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,9 @@ package(default_visibility = ["//visibility:public"])
66
ts_library(
77
name = "reflect_metadata",
88
srcs = [
9-
"src/reflect_metadata_aot.ts",
10-
"src/reflect_metadata_jit.ts",
11-
"src/reflect_metadata_legacy.ts",
12-
":metadata_switch",
9+
"src/reflect_metadata.ts",
1310
],
1411
module_name = "@angular/core/test/bundling/util/src/reflect_metadata",
1512
module_root = "src/reflect_metadata",
1613
deps = ["@npm//reflect-metadata"],
1714
)
18-
19-
# See packages/core/BUILD.bazel.
20-
genrule(
21-
name = "metadata_switch",
22-
outs = ["src/reflect_metadata.ts"],
23-
cmd = "echo import \"'./reflect_metadata_$(compile)';\" > $@",
24-
)

packages/core/test/bundling/util/src/reflect_metadata.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import './reflect_metadata_legacy';
9+
export const UNUSED = true;

packages/core/test/bundling/util/src/reflect_metadata_jit.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

packages/core/test/bundling/util/src/reflect_metadata_legacy.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

packages/private/testing/BUILD.bazel

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ ng_module(
2121

2222
## Controls if Ivy is enabled. (Temporary target until we permanently switch over to Ivy)
2323
##
24-
## This file generates `src/bazel_define_compile_value.ts` file which reexports
25-
## `--define=compile` value as `bazelDefineCompileValue` symbols so that runtime can detect
26-
## which mode it is running in.
24+
## This file generates `src/angular_ivy_enabled.ts` file which exports a truthy value
25+
## whether Ivy should be enabled based on the `--defined=angular_ivy_enabled` value so
26+
## runtime can detect which mode it is running in.
2727
##
28-
## See: `//.bazelrc` where `--define=ivy=legacy` is defined as default.
29-
## See: `./src/bazel_define_compile_value.ts` for more details.
28+
## See: `//.bazelrc` where `--define=angular_ivy_enabled=false` is defined as default.
29+
## See: `./src/angular_ivy_enabled.ts` for more details.
3030
genrule(
31-
name = "bazel_define_compile_value",
32-
outs = ["src/bazel_define_compile_value.ts"],
33-
cmd = "echo export const bazelDefineCompileValue = \"'$(compile)'\"\; > $@",
31+
name = "angular_ivy_enabled",
32+
outs = ["src/angular_ivy_enabled.ts"],
33+
cmd = "echo export const ivyEnabled = \"'True'.toString() == '$(angular_ivy_enabled)'\"\; > $@",
3434
)

packages/core/test/bundling/util/src/reflect_metadata_aot.ts renamed to packages/private/testing/src/angular_ivy_enabled.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
export const UNUSED = true;
9+
/**
10+
* This variable shows if Ivy should be enabled at runtime.
11+
*/
12+
export const ivyEnabled = false;

packages/private/testing/src/bazel_define_compile_value.ts

Lines changed: 0 additions & 12 deletions
This file was deleted.

packages/private/testing/src/ivy_test_selectors.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
* Use of this source code is governed by an MIT-style license that can be
66
* found in the LICENSE file at https://angular.io/license
77
*/
8-
9-
import {bazelDefineCompileValue} from './bazel_define_compile_value';
8+
import {ivyEnabled} from './angular_ivy_enabled';
109

1110
/**
1211
* A function to conditionally include a test or a block of tests only when tests run against Ivy.
@@ -24,7 +23,7 @@ import {bazelDefineCompileValue} from './bazel_define_compile_value';
2423
* ivyEnabled && it(...);
2524
* ```
2625
*/
27-
export const ivyEnabled = 'aot' === (bazelDefineCompileValue as string);
26+
export {ivyEnabled};
2827

2928
/**
3029
* A function to conditionally skip the execution of tests that are not relevant when

0 commit comments

Comments
 (0)