fix(bazel): use //:tsconfig.json as the default for ng_module (#29670)

This matches the behavior of ts_library

PR Close #29670
This commit is contained in:
Alex Eagle 2019-04-02 11:42:58 -07:00 committed by Jason Aden
parent 630aaa6bfb
commit b14537a004
5 changed files with 30 additions and 13 deletions

View File

@ -5,13 +5,17 @@ package(default_visibility = ["//visibility:public"])
load("//tools:defaults.bzl", "karma_web_test")
exports_files([
"tsconfig.json",
"LICENSE",
"protractor-perf.conf.js",
"karma-js.conf.js",
"browser-providers.conf.js",
])
alias(
name = "tsconfig.json",
actual = "//packages:tsconfig-build.json",
)
filegroup(
name = "web_test_bootstrap_scripts",
# do not sort

View File

@ -13,7 +13,7 @@ load(
_protractor_web_test = "protractor_web_test",
_protractor_web_test_suite = "protractor_web_test_suite",
)
load("//packages/bazel/src:ng_module.bzl", _ng_module = "ng_module")
load("//packages/bazel/src:ng_module.bzl", _ng_module = "ng_module_macro")
ng_module = _ng_module
ng_package = _ng_package

View File

@ -736,3 +736,21 @@ This rule extends the [ts_library] rule.
[ts_library]: http://tsetse.info/api/build_defs.html#ts_library
"""
def ng_module_macro(tsconfig = None, **kwargs):
"""Wraps `ng_module` to set the default for the `tsconfig` attribute.
This must be a macro so that the string is converted to a label in the context of the
workspace that declares the `ng_module` target, rather than the workspace that defines
`ng_module`, or the workspace where the build is taking place.
This macro is re-exported as `ng_module` in the public API.
Args:
tsconfig: the label pointing to a tsconfig.json file
**kwargs: remaining args to pass to the ng_module rule
"""
if not tsconfig:
tsconfig = "//:tsconfig.json"
ng_module(tsconfig = tsconfig, **kwargs)

View File

@ -21,6 +21,7 @@ ng_module(
deps = [
"//packages/core",
"@npm//@types",
"@npm//tslib",
],
)

View File

@ -7,7 +7,6 @@ load("@npm_bazel_typescript//:index.bzl", _ts_library = "ts_library")
load("//packages/bazel:index.bzl", _ng_module = "ng_module", _ng_package = "ng_package")
load("//packages/bazel/src:ng_rollup_bundle.bzl", _ng_rollup_bundle = "ng_rollup_bundle")
_DEFAULT_TSCONFIG_BUILD = "//packages:tsconfig-build.json"
_DEFAULT_TSCONFIG_TEST = "//packages:tsconfig-test"
_INTERNAL_NG_MODULE_API_EXTRACTOR = "//packages/bazel/src/api-extractor:api_extractor"
_INTERNAL_NG_MODULE_COMPILER = "//packages/bazel/src/ngc-wrapped"
@ -84,11 +83,8 @@ def ts_library(tsconfig = None, testonly = False, deps = [], module_name = None,
# Match the types[] in //packages:tsconfig-test.json
deps.append("@npm//@types/jasmine")
deps.append("@npm//@types/node")
if not tsconfig:
if testonly:
tsconfig = _DEFAULT_TSCONFIG_TEST
else:
tsconfig = _DEFAULT_TSCONFIG_BUILD
if not tsconfig and testonly:
tsconfig = _DEFAULT_TSCONFIG_TEST
if not module_name:
module_name = _default_module_name(testonly)
@ -108,11 +104,9 @@ def ng_module(name, tsconfig = None, entry_point = None, testonly = False, deps
# Match the types[] in //packages:tsconfig-test.json
deps.append("@npm//@types/jasmine")
deps.append("@npm//@types/node")
if not tsconfig:
if testonly:
tsconfig = _DEFAULT_TSCONFIG_TEST
else:
tsconfig = _DEFAULT_TSCONFIG_BUILD
if not tsconfig and testonly:
tsconfig = _DEFAULT_TSCONFIG_TEST
if not module_name:
module_name = _default_module_name(testonly)
if not entry_point: