build: set a default module_name for ts_library rules (#28051)

PR Close #28051
This commit is contained in:
Alex Eagle 2019-01-10 11:55:20 -08:00 committed by Alex Rickabaugh
parent 45bf911df8
commit 38343a2388
55 changed files with 61 additions and 70 deletions

View File

@ -37,9 +37,14 @@ ts_devserver(
load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary", "rollup_bundle")
filegroup(
name = "empty_node_modules",
)
rollup_bundle(
name = "bundle",
entry_point = "src/main",
node_modules = ":empty_node_modules",
deps = ["//src"],
)

View File

@ -2,24 +2,24 @@
# yarn lockfile v1
"@bazel/bazel-darwin_x64@0.18.0":
version "0.18.0"
resolved "https://registry.yarnpkg.com/@bazel/bazel-darwin_x64/-/bazel-darwin_x64-0.18.0.tgz#bab437605a702279d42f59caa4741bb327eb7dbc"
integrity sha512-um2OzgLL2Gd/W6joOpvrSTcqpnupliPNpwe/uE7sB0huBSJ/4Im0w2IlCTI6C7OfgMcbpUj4YxgUa9T6u6WY6w==
"@bazel/bazel-darwin_x64@0.20.0":
version "0.20.0"
resolved "https://registry.yarnpkg.com/@bazel/bazel-darwin_x64/-/bazel-darwin_x64-0.20.0.tgz#648d61c32a3c5fccb7bf70b753071b6e54b11f21"
integrity sha512-zeoeVK504341GfnaxdaB4pFzQV0YOK1HLiYj3/ocamPFxAJRh9abvKB8iOpqD5Oal0j7VsINxnXCjovp9a4urA==
"@bazel/bazel-linux_x64@0.18.0":
version "0.18.0"
resolved "https://registry.yarnpkg.com/@bazel/bazel-linux_x64/-/bazel-linux_x64-0.18.0.tgz#0c02b2404ec95c180e17615cc7079ee07df48a69"
integrity sha512-Rq8X8bL6SgQvbOHnfPhSgF6hp+f6Fbt2w6pRmBlFvV1J+CeUyrSrrRXfnnO1bjIuq05Ur3mV8ULA0qK6rtA5lQ==
"@bazel/bazel-linux_x64@0.20.0":
version "0.20.0"
resolved "https://registry.yarnpkg.com/@bazel/bazel-linux_x64/-/bazel-linux_x64-0.20.0.tgz#2568628a0d0b85dcc69d0ab701b1d6e10551357d"
integrity sha512-PpHzoEqfXty8dc1/p1tVFXtbPyrE1n0N79QmYePjJ5mJMyW7uBF/zV4IajYY8+IpJEcDVq5v4BavSexOmVJRmA==
"@bazel/bazel-win32_x64@0.18.0":
version "0.18.0"
resolved "https://registry.yarnpkg.com/@bazel/bazel-win32_x64/-/bazel-win32_x64-0.18.0.tgz#aa4575fb00066dcf59a6d464971774dea6a0bafd"
integrity sha512-U2TbfK8B7dc3JqXSFwj2oXCQrxEaSzCCUkAHjAOIGOKzx/HLKIKs+NJj9IQkLLr7BsMU+Qqzo8aqo11E+Vs+aA==
"@bazel/bazel-win32_x64@0.20.0":
version "0.20.0"
resolved "https://registry.yarnpkg.com/@bazel/bazel-win32_x64/-/bazel-win32_x64-0.20.0.tgz#af7d041dae4c066e7aa8618949e2de1aad07495e"
integrity sha512-3bqHXFBvLnbvNzr1KCQ1zryTYvHMoQffaWVekbckgPyT2VPEj3abuB91+DrRYmZdPjcgPYnjnyanxZHDkKuF2g==
"@bazel/bazel@file:../../node_modules/@bazel/bazel":
version "0.18.0"
version "0.20.0"
optionalDependencies:
"@bazel/bazel-darwin_x64" "0.18.0"
"@bazel/bazel-linux_x64" "0.18.0"
"@bazel/bazel-win32_x64" "0.18.0"
"@bazel/bazel-darwin_x64" "0.20.0"
"@bazel/bazel-linux_x64" "0.20.0"
"@bazel/bazel-win32_x64" "0.20.0"

View File

@ -10,7 +10,6 @@ ng_module(
"src/**/*.ts",
],
),
module_name = "@angular/animations",
deps = [
"//packages/core",
],

View File

@ -12,7 +12,6 @@ ng_module(
"src/**/*.ts",
],
),
module_name = "@angular/animations/browser",
deps = [
"//packages/animations",
"//packages/core",

View File

@ -7,7 +7,6 @@ load("//tools:defaults.bzl", "ng_module")
ng_module(
name = "testing",
srcs = glob(["**/*.ts"]),
module_name = "@angular/animations/browser/testing",
deps = [
"//packages/animations",
"//packages/animations/browser",

View File

@ -10,7 +10,6 @@ ts_library(
"src/**/*.ts",
],
),
module_name = "@angular/benchpress",
deps = [
"//packages:types",
"//packages/core",

View File

@ -10,7 +10,6 @@ ng_module(
"src/**/*.ts",
],
),
module_name = "@angular/common",
deps = [
"//packages/core",
"@rxjs",

View File

@ -12,7 +12,6 @@ ng_module(
"src/**/*.ts",
],
),
module_name = "@angular/common/http",
deps = [
"//packages/common",
"//packages/core",

View File

@ -12,7 +12,6 @@ ng_module(
"src/**/*.ts",
],
),
module_name = "@angular/common/http/testing",
deps = [
"//packages/common/http",
"//packages/core",

View File

@ -8,7 +8,6 @@ ts_library(
["**/*.ts"],
exclude = ["closure-locale.ts"],
),
module_name = "@angular/common/locales",
)
npm_package(

View File

@ -7,7 +7,6 @@ load("//tools:defaults.bzl", "ng_module")
ng_module(
name = "testing",
srcs = glob(["**/*.ts"]),
module_name = "@angular/common/testing",
deps = [
"//packages/common",
"//packages/core",

View File

@ -20,7 +20,6 @@ ts_library(
"src/integrationtest/**/*.ts",
],
),
module_name = "@angular/compiler-cli",
tsconfig = ":tsconfig",
deps = [
"//packages/compiler",

View File

@ -8,7 +8,6 @@ ts_library(
"*.ts",
"**/*.ts",
]),
module_name = "@angular/compiler-cli/src/ngcc",
deps = [
"//packages:types",
"//packages/compiler",

View File

@ -8,7 +8,6 @@ ts_library(
"index.ts",
"src/**/*.ts",
]),
module_name = "@angular/compiler-cli/src/ngtsc/annotations",
deps = [
"//packages/compiler",
"//packages/compiler-cli/src/ngtsc/diagnostics",

View File

@ -8,7 +8,6 @@ ts_library(
"index.ts",
"src/**/*.ts",
]),
module_name = "@angular/compiler-cli/src/ngtsc/diagnostics",
deps = [
"//packages/compiler",
"@ngdeps//typescript",

View File

@ -8,7 +8,6 @@ ts_library(
"index.ts",
"src/*.ts",
]),
module_name = "@angular/compiler-cli/src/ngtsc/imports",
deps = [
"//packages:types",
"//packages/compiler",

View File

@ -8,6 +8,5 @@ ts_library(
"index.ts",
"src/**/*.ts",
]),
module_name = "@angular/compiler-cli/src/ngtsc/reflection",
deps = ["@ngdeps//typescript"],
)

View File

@ -8,7 +8,6 @@ ts_library(
"index.ts",
"src/**/*.ts",
]),
module_name = "@angular/compiler-cli/src/ngtsc/shims",
deps = [
"//packages/compiler",
"//packages/compiler-cli/src/ngtsc/imports",

View File

@ -8,7 +8,6 @@ ts_library(
"index.ts",
"src/**/*.ts",
]),
module_name = "@angular/compiler-cli/src/ngtsc/switch",
deps = [
"//packages/compiler",
"@ngdeps//typescript",

View File

@ -8,7 +8,6 @@ ts_library(
"index.ts",
"src/**/*.ts",
]),
module_name = "@angular/compiler-cli/src/ngtsc/transform",
deps = [
"//packages/compiler",
"//packages/compiler-cli/src/ngtsc/diagnostics",

View File

@ -5,7 +5,6 @@ load("//tools:defaults.bzl", "ts_library")
ts_library(
name = "translator",
srcs = glob(["**/*.ts"]),
module_name = "@angular/compiler-cli/src/ngtsc/translator",
deps = [
"//packages:types",
"//packages/compiler",

View File

@ -5,7 +5,6 @@ load("//tools:defaults.bzl", "ts_library")
ts_library(
name = "typecheck",
srcs = glob(["**/*.ts"]),
module_name = "@angular/compiler-cli/src/ngtsc/typecheck",
deps = [
"//packages:types",
"//packages/compiler",

View File

@ -8,7 +8,6 @@ ts_library(
"index.ts",
"src/**/*.ts",
]),
module_name = "@angular/compiler-cli/src/ngtsc/util",
deps = [
"//packages:types",
"@ngdeps//@types/node",

View File

@ -10,7 +10,6 @@ ts_library(
"src/**/*.ts",
],
),
module_name = "@angular/compiler",
)
ng_package(

View File

@ -10,7 +10,6 @@ ng_module(
["**/*.ts"],
exclude = ["testing.ts"],
),
module_name = "@angular/compiler/testing",
deps = [
"//packages:types",
"//packages/compiler",

View File

@ -10,7 +10,6 @@ ng_module(
"src/**/*.ts",
],
),
module_name = "@angular/core",
deps = [
"//packages:types",
"//packages/core/src/compiler",

View File

@ -13,7 +13,6 @@ ts_library(
"**/*.ts",
],
),
module_name = "@angular/core/compiler",
deps = [
"//packages/core/src/util",
],

View File

@ -12,7 +12,6 @@ ts_library(
"**/*.ts",
],
),
module_name = "@angular/core/di/interface",
deps = [
"//packages/core/src/interface",
"//packages/core/src/util",

View File

@ -12,5 +12,4 @@ ts_library(
"*.ts",
],
),
module_name = "@angular/core/interface",
)

View File

@ -12,7 +12,6 @@ ts_library(
"**/*.ts",
],
),
module_name = "@angular/core/reflection",
deps = [
"//packages/core/src/interface",
"//packages/core/src/util",

View File

@ -12,7 +12,6 @@ ts_library(
"**/*.ts",
],
),
module_name = "@angular/core/util",
deps = [
"//packages/core/src/interface",
"@rxjs",

View File

@ -9,7 +9,6 @@ ng_module(
srcs = glob(
["**/*.ts"],
),
module_name = "@angular/core/testing",
deps = [
"//packages:types",
"//packages/compiler",

View File

@ -10,7 +10,6 @@ ng_module(
"src/**/*.ts",
],
),
module_name = "@angular/elements",
deps = [
"//packages/core",
"//packages/platform-browser",

View File

@ -10,7 +10,6 @@ ng_module(
"src/**/*.ts",
],
),
module_name = "@angular/forms",
deps = [
"//packages/core",
"//packages/platform-browser",

View File

@ -10,7 +10,6 @@ ng_module(
"src/**/*.ts",
],
),
module_name = "@angular/http",
deps = [
"//packages/core",
"//packages/platform-browser",

View File

@ -7,7 +7,6 @@ load("//tools:defaults.bzl", "ng_module")
ng_module(
name = "testing",
srcs = glob(["**/*.ts"]),
module_name = "@angular/http/testing",
deps = [
"//packages/core",
"//packages/http",

View File

@ -10,7 +10,6 @@ ts_library(
"src/**/*.ts",
],
),
module_name = "@angular/language-service",
deps = [
"//packages:types",
"//packages/compiler",

View File

@ -10,7 +10,6 @@ ng_module(
"src/**/*.ts",
],
),
module_name = "@angular/platform-browser-dynamic",
deps = [
"//packages:types",
"//packages/common",

View File

@ -7,7 +7,6 @@ load("//tools:defaults.bzl", "ng_module")
ng_module(
name = "testing",
srcs = glob(["**/*.ts"]),
module_name = "@angular/platform-browser-dynamic/testing",
deps = [
"//packages/compiler",
"//packages/compiler/testing",

View File

@ -10,7 +10,6 @@ ng_module(
"src/**/*.ts",
],
),
module_name = "@angular/platform-browser",
deps = [
"//packages:types",
"//packages/common",

View File

@ -12,7 +12,6 @@ ng_module(
"src/**/*.ts",
],
),
module_name = "@angular/platform-browser/animations",
deps = [
"//packages/animations",
"//packages/animations/browser",

View File

@ -7,7 +7,6 @@ load("//tools:defaults.bzl", "ng_module")
ng_module(
name = "testing",
srcs = glob(["**/*.ts"]),
module_name = "@angular/platform-browser/testing",
deps = [
"//packages/core",
"//packages/core/testing",

View File

@ -10,7 +10,6 @@ ng_module(
"src/**/*.ts",
],
),
module_name = "@angular/platform-server",
deps = [
"//packages/animations/browser",
"//packages/common",

View File

@ -7,7 +7,6 @@ load("//tools:defaults.bzl", "ng_module")
ng_module(
name = "testing",
srcs = glob(["**/*.ts"]),
module_name = "@angular/platform-server/testing",
deps = [
"//packages/core",
"//packages/platform-browser-dynamic/testing",

View File

@ -10,7 +10,6 @@ ng_module(
"src/**/*.ts",
],
),
module_name = "@angular/platform-webworker-dynamic",
deps = [
"//packages:types",
"//packages/common",

View File

@ -10,7 +10,6 @@ ng_module(
"src/**/*.ts",
],
),
module_name = "@angular/platform-webworker",
deps = [
"//packages:types",
"//packages/common",

View File

@ -10,7 +10,6 @@ ng_module(
"src/**/*.ts",
],
),
module_name = "@angular/router",
deps = [
"//packages/common",
"//packages/core",

View File

@ -7,7 +7,6 @@ load("//tools:defaults.bzl", "ng_module")
ng_module(
name = "testing",
srcs = glob(["**/*.ts"]),
module_name = "@angular/router/testing",
deps = [
"//packages/common",
"//packages/common/testing",

View File

@ -12,7 +12,6 @@ ng_module(
"src/**/*.ts",
],
),
module_name = "@angular/router/upgrade",
deps = [
"//packages/common",
"//packages/core",

View File

@ -10,7 +10,6 @@ ng_module(
"src/**/*.ts",
],
),
module_name = "@angular/service-worker",
deps = [
"//packages/common",
"//packages/core",

View File

@ -10,6 +10,5 @@ ng_module(
"*.ts",
"src/**/*.ts",
]),
module_name = "@angular/service-worker/config",
deps = ["//packages/core"],
)

View File

@ -6,7 +6,6 @@ ng_module(
name = "testing",
testonly = True,
srcs = glob(["**/*.ts"]),
module_name = "@angular/service-worker/testing",
deps = [
"//packages/core",
"@rxjs",

View File

@ -11,7 +11,6 @@ ng_module(
"src/dynamic/**/*.ts",
],
),
module_name = "@angular/upgrade",
deps = [
"//packages/core",
"//packages/platform-browser",

View File

@ -15,7 +15,6 @@ ng_module(
"src/static/**/*.ts",
],
),
module_name = "@angular/upgrade/static",
deps = [
"//packages/core",
"//packages/platform-browser",

View File

@ -44,7 +44,38 @@ PKG_GROUP_REPLACEMENTS = {
]""" % ",\n ".join(["\"%s\"" % s for s in ANGULAR_SCOPED_PACKAGES]),
}
def ts_library(tsconfig = None, testonly = False, deps = [], **kwargs):
def _default_module_name(testonly):
""" Provide better defaults for package names.
e.g. rather than angular/packages/core/testing we want @angular/core/testing
TODO(alexeagle): we ought to supply a default module name for every library in the repo.
But we short-circuit below in cases that are currently not working.
"""
pkg = native.package_name()
if testonly:
# Some tests currently rely on the long-form package names
return None
if pkg.startswith("packages/bazel"):
# Avoid infinite recursion in the ViewEngine compiler. Error looks like:
# Compiling Angular templates (ngc) //packages/bazel/test/ngc-wrapped/empty:empty failed (Exit 1)
# : RangeError: Maximum call stack size exceeded
# at normalizeString (path.js:57:25)
# at Object.normalize (path.js:1132:12)
# at Object.join (path.js:1167:18)
# at resolveModule (execroot/angular/bazel-out/host/bin/packages/bazel/src/ngc-wrapped/ngc-wrapped.runfiles/angular/packages/compiler-cli/src/metadata/bundler.js:582:50)
# at MetadataBundler.exportAll (execroot/angular/bazel-out/host/bin/packages/bazel/src/ngc-wrapped/ngc-wrapped.runfiles/angular/packages/compiler-cli/src/metadata/bundler.js:119:42)
# at MetadataBundler.exportAll (execroot/angular/bazel-out/host/bin/packages/bazel/src/ngc-wrapped/ngc-wrapped.runfiles/angular/packages/compiler-cli/src/metadata/bundler.js:121:52)
return None
if pkg.startswith("packages/"):
return "@angular/" + pkg[len("packages/"):]
return None
def ts_library(tsconfig = None, testonly = False, deps = [], module_name = None, **kwargs):
"""Default values for ts_library"""
deps = deps + ["@ngdeps//tslib"]
if testonly:
@ -57,15 +88,19 @@ def ts_library(tsconfig = None, testonly = False, deps = [], **kwargs):
else:
tsconfig = _DEFAULT_TSCONFIG_BUILD
if not module_name:
module_name = _default_module_name(testonly)
_ts_library(
tsconfig = tsconfig,
testonly = testonly,
deps = deps,
node_modules = _DEFAULT_TS_TYPINGS,
module_name = module_name,
**kwargs
)
def ng_module(name, tsconfig = None, entry_point = None, testonly = False, deps = [], **kwargs):
def ng_module(name, tsconfig = None, entry_point = None, testonly = False, deps = [], module_name = None, **kwargs):
"""Default values for ng_module"""
deps = deps + ["@ngdeps//tslib"]
if testonly:
@ -77,6 +112,8 @@ def ng_module(name, tsconfig = None, entry_point = None, testonly = False, deps
tsconfig = _DEFAULT_TSCONFIG_TEST
else:
tsconfig = _DEFAULT_TSCONFIG_BUILD
if not module_name:
module_name = _default_module_name(testonly)
if not entry_point:
entry_point = "public_api.ts"
_ng_module(
@ -89,6 +126,7 @@ def ng_module(name, tsconfig = None, entry_point = None, testonly = False, deps
compiler = _INTERNAL_NG_MODULE_COMPILER,
ng_xi18n = _INTERNAL_NG_MODULE_XI18N,
node_modules = _DEFAULT_TS_TYPINGS,
module_name = module_name,
**kwargs
)