mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
build: test cdk with bazel (#13575)
* build: test cdk with bazel * Add comment for bazel tsconfig files * CDK tsconfig sync with Bazel build tsconfig
This commit is contained in:
committed by
Andrew Seguin
parent
85f04db62a
commit
d128fffcd6
+3
-3
@@ -47,6 +47,6 @@ build --workspace_status_command=./tools/bazel-stamp-vars.sh
|
||||
# running as daemons, and cache SourceFile AST's to reduce parse time.
|
||||
build --strategy=TypeScriptCompile=worker --strategy=AngularTemplateCompile=worker
|
||||
|
||||
# Use the new "ngtsc" compiler strategy. We don't want to compile with Ivy nor with the
|
||||
# legacy compiler that doesn't handle `providedIn` properly.
|
||||
build --define=compile=local
|
||||
# Use the legacy AOT compiler strategy. We don't want to compile with Ivy nor with "ngtsc" which
|
||||
# does not generate factory files which are needed for AOT.
|
||||
build --define=compile=legacy
|
||||
|
||||
+54
-4
@@ -2,12 +2,32 @@
|
||||
|
||||
load("@angular//:index.bzl", _ng_module = "ng_module")
|
||||
load("@build_bazel_rules_nodejs//:defs.bzl", _jasmine_node_test = "jasmine_node_test")
|
||||
load("@build_bazel_rules_typescript//:defs.bzl", _ts_library = "ts_library")
|
||||
load("@build_bazel_rules_typescript//:defs.bzl", _ts_library = "ts_library",
|
||||
_ts_web_test_suite = "ts_web_test_suite")
|
||||
|
||||
def ts_library(deps = [], **kwargs):
|
||||
ts_library(**kwargs)
|
||||
DEFAULT_TSCONFIG_BUILD = "//src:bazel-tsconfig-build.json"
|
||||
DEFAULT_TSCONFIG_TEST = "//src:bazel-tsconfig-test.json"
|
||||
|
||||
def _getDefaultTsConfig(testonly):
|
||||
if testonly:
|
||||
return DEFAULT_TSCONFIG_TEST
|
||||
else:
|
||||
return DEFAULT_TSCONFIG_BUILD
|
||||
|
||||
def ts_library(tsconfig = None, testonly = False, **kwargs):
|
||||
if not tsconfig:
|
||||
tsconfig = _getDefaultTsConfig(testonly)
|
||||
|
||||
_ts_library(
|
||||
tsconfig = tsconfig,
|
||||
testonly = testonly,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
def ng_module(deps = [], tsconfig = None, testonly = False, **kwargs):
|
||||
if not tsconfig:
|
||||
tsconfig = _getDefaultTsConfig(testonly)
|
||||
|
||||
def ng_module(deps = [], **kwargs):
|
||||
local_deps = [
|
||||
# Since we use the TypeScript import helpers (tslib) for each TypeScript configuration,
|
||||
# we declare TSLib as default dependency
|
||||
@@ -16,6 +36,8 @@ def ng_module(deps = [], **kwargs):
|
||||
|
||||
_ng_module(
|
||||
deps = local_deps,
|
||||
tsconfig = tsconfig,
|
||||
testonly = testonly,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
@@ -30,3 +52,31 @@ def jasmine_node_test(deps = [], **kwargs):
|
||||
deps = local_deps,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
def ng_test_library(deps = [], tsconfig = None, **kwargs):
|
||||
local_deps = [
|
||||
# We declare "@angular/core" and "@angular/core/testing" as default dependencies because
|
||||
# all Angular component unit tests use the `TestBed` and `Component` exports.
|
||||
"@angular//packages/core",
|
||||
"@angular//packages/core/testing",
|
||||
"@npm//@types/jasmine",
|
||||
] + deps;
|
||||
|
||||
ts_library(
|
||||
testonly = 1,
|
||||
deps = local_deps,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
def ng_web_test_suite(deps = [], srcs = [], **kwargs):
|
||||
_ts_web_test_suite(
|
||||
# Required for running the compiled ng modules that use TypeScript import helpers.
|
||||
srcs = ["@npm//node_modules/tslib:tslib.js"] + srcs,
|
||||
# Depend on our custom test initialization script. This needs to be the first dependency.
|
||||
deps = ["//test:angular_test_init"] + deps,
|
||||
bootstrap = [
|
||||
"@npm//node_modules/zone.js:dist/zone-testing-bundle.js",
|
||||
"@npm//node_modules/reflect-metadata:Reflect.js",
|
||||
],
|
||||
**kwargs
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user