build: refactor ambient node & jasmine types so they are only included where needed (#25528)

PR Close #25528
This commit is contained in:
Greg Magolan
2018-08-14 16:18:26 -07:00
committed by Jason Aden
parent 292b435495
commit 7eed4ee837
20 changed files with 67 additions and 12 deletions

View File

@ -4,7 +4,8 @@ load("@build_bazel_rules_typescript//:defs.bzl", _ts_library = "ts_library", _ts
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")
DEFAULT_TSCONFIG = "//packages:tsconfig-build.json"
DEFAULT_TSCONFIG_BUILD = "//packages:tsconfig-build.json"
DEFAULT_TSCONFIG_TEST = "//packages:tsconfig-test.json"
DEFAULT_NODE_MODULES = "@angular_deps//:node_modules"
# Packages which are versioned together on npm
@ -38,27 +39,36 @@ PKG_GROUP_REPLACEMENTS = {
]""" % ",\n ".join(["\"%s\"" % s for s in ANGULAR_SCOPED_PACKAGES])
}
def ts_library(tsconfig = None, node_modules = DEFAULT_NODE_MODULES, **kwargs):
def ts_library(tsconfig = None, node_modules = DEFAULT_NODE_MODULES, testonly = False, **kwargs):
if not tsconfig:
tsconfig = DEFAULT_TSCONFIG
_ts_library(tsconfig = tsconfig, node_modules = node_modules, **kwargs)
if testonly:
tsconfig = DEFAULT_TSCONFIG_TEST
else:
tsconfig = DEFAULT_TSCONFIG_BUILD
_ts_library(tsconfig = tsconfig, node_modules = node_modules, testonly = testonly, **kwargs)
def ng_module(name, tsconfig = None, entry_point = None, node_modules = DEFAULT_NODE_MODULES, **kwargs):
def ng_module(name, tsconfig = None, entry_point = None, node_modules = DEFAULT_NODE_MODULES, testonly = False, **kwargs):
if not tsconfig:
tsconfig = DEFAULT_TSCONFIG
if testonly:
tsconfig = DEFAULT_TSCONFIG_TEST
else:
tsconfig = DEFAULT_TSCONFIG_BUILD
if not entry_point:
entry_point = "public_api.ts"
_ng_module(name = name, flat_module_out_file = name, tsconfig = tsconfig, entry_point = entry_point, node_modules = node_modules, **kwargs)
_ng_module(name = name, flat_module_out_file = name, tsconfig = tsconfig, entry_point = entry_point, node_modules = node_modules, testonly = testonly, **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, **kwargs):
def ivy_ng_module(name, tsconfig = None, entry_point = None, testonly = False, **kwargs):
if not tsconfig:
tsconfig = DEFAULT_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, **kwargs)
_internal_global_ng_module(name = name, flat_module_out_file = name, tsconfig = tsconfig, entry_point = entry_point, testonly = testonly, **kwargs)
def ng_package(name, readme_md = None, license_banner = None, **kwargs):
if not readme_md:

View File

@ -5,6 +5,7 @@ load("@build_bazel_rules_nodejs//:defs.bzl", "jasmine_node_test")
ts_library(
name = "lib",
testonly = True,
srcs = glob(
["**/*.ts"],
exclude = [

View File

@ -28,6 +28,7 @@ def js_expected_symbol_test(name, src, golden, **kwargs):
nodejs_binary(
name = name + '.accept',
testonly = True,
data = all_data,
entry_point = entry_point,
templated_args = ["$(location %s)" % src, "$(location %s)" % golden, '--accept'],

View File

@ -48,6 +48,7 @@ def ts_api_guardian_test(name, golden, actual, data = [], **kwargs):
nodejs_binary(
name = name + ".accept",
testonly = True,
data = data,
node_modules = "@ts-api-guardian_runtime_deps//:node_modules",
entry_point = "angular/tools/ts-api-guardian/bin/ts-api-guardian",