From f7ba4b2ff982b5da1795d1ac2e7d9567593d4bce Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Thu, 15 Nov 2018 14:18:39 -0800 Subject: [PATCH] fix(ivy): remove obsolete ng_module code for global and jit mode (#27278) These paths are no longer needed / used. I had to disable one jit mode spec because it fails now that we actually run it. I root caused the jit test failure as missing forwardRef support. See FW-645. PR Close #27278 --- packages/bazel/src/ng_module.bzl | 32 +++---------------- .../injector_def/ivy_build/app/BUILD.bazel | 5 +-- .../ivy_build/app/test/BUILD.bazel | 6 ++++ .../ivy_build/app/test/module_spec.ts | 1 + .../bundling/hello_world_i18n/BUILD.bazel | 5 ++- tools/defaults.bzl | 31 ------------------ 6 files changed, 16 insertions(+), 64 deletions(-) diff --git a/packages/bazel/src/ng_module.bzl b/packages/bazel/src/ng_module.bzl index 5ff45c50d2..23f072c4c7 100644 --- a/packages/bazel/src/ng_module.bzl +++ b/packages/bazel/src/ng_module.bzl @@ -22,7 +22,7 @@ load( def compile_strategy(ctx): """Detect which strategy should be used to implement ng_module. - Depending on the value of the 'compile' define flag or the '_global_mode' attribute, ng_module + Depending on the value of the 'compile' define flag, ng_module can be implemented in various ways. This function reads the configuration passed by the user and determines which mode is active. @@ -30,19 +30,16 @@ def compile_strategy(ctx): ctx: skylark rule execution context Returns: - one of 'legacy', 'aot', 'jit', or 'global' depending on the configuration in ctx + one of 'legacy' or 'aot' depending on the configuration in ctx """ strategy = "legacy" if "compile" in ctx.var: strategy = ctx.var["compile"] - if strategy not in ["legacy", "aot", "jit"]: + if strategy not in ["legacy", "aot"]: fail("Unknown --define=compile value '%s'" % strategy) - if strategy == "legacy" and hasattr(ctx.attr, "_global_mode") and ctx.attr._global_mode: - strategy = "global" - return strategy def _compiler_name(ctx): @@ -58,12 +55,8 @@ def _compiler_name(ctx): strategy = compile_strategy(ctx) if strategy == "legacy": return "ngc" - elif strategy == "global": - return "ngc.ivy" elif strategy == "aot": return "ngtsc" - elif strategy == "jit": - return "tsc" else: fail("unreachable") @@ -80,12 +73,8 @@ def _enable_ivy_value(ctx): strategy = compile_strategy(ctx) if strategy == "legacy": return False - elif strategy == "global": - return True elif strategy == "aot": return "ngtsc" - elif strategy == "jit": - return "tsc" else: fail("unreachable") @@ -101,7 +90,7 @@ def _include_ng_files(ctx): """ strategy = compile_strategy(ctx) - return strategy == "legacy" or strategy == "global" + return strategy == "legacy" def _basename_of(ctx, file): ext_len = len(".ts") @@ -636,16 +625,3 @@ This rule extends the [ts_library] rule. [ts_library]: http://tsetse.info/api/build_defs.html#ts_library """ - -# TODO(alxhub): this rule causes legacy ngc to produce Ivy outputs from global analysis information. -# It exists to facilitate testing of the Ivy runtime until ngtsc is mature enough to be used -# instead, and should be removed once ngtsc is capable of fulfilling the same requirements. -internal_global_ng_module = rule( - implementation = _ng_module_impl, - attrs = dict(NG_MODULE_RULE_ATTRS, **{ - "_global_mode": attr.bool( - default = True, - ), - }), - outputs = COMMON_OUTPUTS, -) diff --git a/packages/compiler-cli/integrationtest/bazel/injector_def/ivy_build/app/BUILD.bazel b/packages/compiler-cli/integrationtest/bazel/injector_def/ivy_build/app/BUILD.bazel index 15a6b28c75..0d0572a43e 100644 --- a/packages/compiler-cli/integrationtest/bazel/injector_def/ivy_build/app/BUILD.bazel +++ b/packages/compiler-cli/integrationtest/bazel/injector_def/ivy_build/app/BUILD.bazel @@ -1,9 +1,9 @@ package(default_visibility = ["//visibility:public"]) -load("//tools:defaults.bzl", "ivy_ng_module") +load("//tools:defaults.bzl", "ng_module") load("//packages/bazel/src:ng_rollup_bundle.bzl", "ng_rollup_bundle") -ivy_ng_module( +ng_module( name = "app", srcs = glob( [ @@ -11,6 +11,7 @@ ivy_ng_module( ], ), module_name = "app_built", + tags = ["ivy-only"], deps = [ "//packages/core", "@rxjs", diff --git a/packages/compiler-cli/integrationtest/bazel/injector_def/ivy_build/app/test/BUILD.bazel b/packages/compiler-cli/integrationtest/bazel/injector_def/ivy_build/app/test/BUILD.bazel index bf0dc25290..5de7233cc1 100644 --- a/packages/compiler-cli/integrationtest/bazel/injector_def/ivy_build/app/test/BUILD.bazel +++ b/packages/compiler-cli/integrationtest/bazel/injector_def/ivy_build/app/test/BUILD.bazel @@ -10,9 +10,14 @@ ts_library( "**/*.ts", ], ), + tags = [ + "ivy-only", + "fixme-ivy-aot", + ], deps = [ "//packages/compiler-cli/integrationtest/bazel/injector_def/ivy_build/app", "//packages/core", + "//packages/private/testing", ], ) @@ -20,6 +25,7 @@ jasmine_node_test( name = "test", bootstrap = ["angular/tools/testing/init_node_spec.js"], tags = [ + "ivy-only", "fixme-ivy-aot", ], deps = [ diff --git a/packages/compiler-cli/integrationtest/bazel/injector_def/ivy_build/app/test/module_spec.ts b/packages/compiler-cli/integrationtest/bazel/injector_def/ivy_build/app/test/module_spec.ts index 9b99d84fa5..ff37b84043 100644 --- a/packages/compiler-cli/integrationtest/bazel/injector_def/ivy_build/app/test/module_spec.ts +++ b/packages/compiler-cli/integrationtest/bazel/injector_def/ivy_build/app/test/module_spec.ts @@ -7,6 +7,7 @@ */ import {Injectable, InjectionToken, Injector, NgModule, createInjector, forwardRef} from '@angular/core'; +import {fixmeIvy} from '@angular/private/testing'; import {AOT_TOKEN, AotModule, AotService} from 'app_built/src/module'; describe('Ivy NgModule', () => { diff --git a/packages/core/test/bundling/hello_world_i18n/BUILD.bazel b/packages/core/test/bundling/hello_world_i18n/BUILD.bazel index eb65a2e64e..c6508680db 100644 --- a/packages/core/test/bundling/hello_world_i18n/BUILD.bazel +++ b/packages/core/test/bundling/hello_world_i18n/BUILD.bazel @@ -1,12 +1,11 @@ package(default_visibility = ["//visibility:public"]) -load("//tools:defaults.bzl", "ivy_ng_module", "ng_rollup_bundle", "ts_library") +load("//tools:defaults.bzl", "ng_module", "ng_rollup_bundle", "ts_library") load("//tools/http-server:http_server.bzl", "http_server") -ivy_ng_module( +ng_module( name = "hello_world_i18n", srcs = ["index.ts"], - tags = ["ivy-only"], deps = [ "//packages/core", ], diff --git a/tools/defaults.bzl b/tools/defaults.bzl index 464564ef60..96e1583313 100644 --- a/tools/defaults.bzl +++ b/tools/defaults.bzl @@ -3,7 +3,6 @@ load("@build_bazel_rules_nodejs//:defs.bzl", _jasmine_node_test = "jasmine_node_test", _nodejs_binary = "nodejs_binary", _npm_package = "npm_package") load("@build_bazel_rules_typescript//:defs.bzl", _ts_library = "ts_library", _ts_web_test_suite = "ts_web_test_suite") load("//packages/bazel:index.bzl", _ng_module = "ng_module", _ng_package = "ng_package") -load("//packages/bazel/src:ng_module.bzl", _internal_global_ng_module = "internal_global_ng_module") load("//packages/bazel/src:ng_rollup_bundle.bzl", _ng_rollup_bundle = "ng_rollup_bundle") _DEFAULT_TSCONFIG_BUILD = "//packages:tsconfig-build.json" @@ -92,36 +91,6 @@ def ng_module(name, tsconfig = None, entry_point = None, testonly = False, deps **kwargs ) -# ivy_ng_module behaves like ng_module, and under --define=compile=legacy it runs ngc with global -# analysis but produces Ivy outputs. Under other compile modes, it behaves as ng_module. -# TODO(alxhub): remove when ngtsc supports the same use cases. -def ivy_ng_module(name, tsconfig = None, entry_point = None, testonly = False, deps = [], **kwargs): - """Default values for ivy_ng_module""" - deps = deps + ["@ngdeps//tslib"] - if testonly: - # Match the types[] in //packages:tsconfig-test.json - deps.append("@ngdeps//@types/jasmine") - deps.append("@ngdeps//@types/node") - if not tsconfig: - if testonly: - tsconfig = _DEFAULT_TSCONFIG_TEST - else: - tsconfig = _DEFAULT_TSCONFIG_BUILD - if not entry_point: - entry_point = "public_api.ts" - _internal_global_ng_module( - name = name, - flat_module_out_file = name, - tsconfig = tsconfig, - entry_point = entry_point, - testonly = testonly, - deps = deps, - compiler = _INTERNAL_NG_MODULE_COMPILER, - ng_xi18n = _INTERNAL_NG_MODULE_XI18N, - node_modules = _DEFAULT_TS_TYPINGS, - **kwargs - ) - def ng_package(name, readme_md = None, license_banner = None, deps = [], **kwargs): """Default values for ng_package""" if not readme_md: