Skip to content

Commit

Permalink
fix(ivy): remove obsolete ng_module code for global and jit mode (ang…
Browse files Browse the repository at this point in the history
…ular#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 angular#27278
  • Loading branch information
IgorMinar authored and ngfelixl committed Jan 27, 2019
1 parent 2db4c50 commit c5a8797
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 64 deletions.
32 changes: 4 additions & 28 deletions packages/bazel/src/ng_module.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,24 @@ 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.
Args:
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):
Expand All @@ -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")

Expand All @@ -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")

Expand All @@ -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")
Expand Down Expand Up @@ -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,
)
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
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(
[
"src/**/*.ts",
],
),
module_name = "app_built",
tags = ["ivy-only"],
deps = [
"//packages/core",
"@rxjs",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,22 @@ 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",
],
)

jasmine_node_test(
name = "test",
bootstrap = ["angular/tools/testing/init_node_spec.js"],
tags = [
"ivy-only",
"fixme-ivy-aot",
],
deps = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
5 changes: 2 additions & 3 deletions packages/core/test/bundling/hello_world_i18n/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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",
],
Expand Down
31 changes: 0 additions & 31 deletions tools/defaults.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit c5a8797

Please sign in to comment.