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
This commit is contained in:
Igor Minar 2018-11-15 14:18:39 -08:00 committed by Jason Aden
parent 572fd7a79a
commit f7ba4b2ff9
6 changed files with 16 additions and 64 deletions

View File

@ -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,
)

View File

@ -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",

View File

@ -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 = [

View File

@ -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', () => {

View File

@ -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",
],

View File

@ -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: