angular-cn/packages/core/test/bundling/todo/BUILD.bazel

124 lines
2.4 KiB
Python
Raw Normal View History

package(default_visibility = ["//visibility:public"])
load("//tools:defaults.bzl", "jasmine_node_test", "ng_module", "ng_rollup_bundle", "ts_library")
load("//tools/symbol-extractor:index.bzl", "js_expected_symbol_test")
load("@build_bazel_rules_nodejs//:defs.bzl", "http_server")
load("@npm_bazel_typescript//:index.bzl", "ts_devserver")
ng_module(
name = "todo",
srcs = ["index.ts"],
tags = [
"ivy-only",
],
deps = [
"//packages/common",
"//packages/core",
"//packages/core/test/bundling/util:reflect_metadata",
],
)
ng_rollup_bundle(
name = "bundle",
entry_point = ":index.ts",
tags = [
"ivy-only",
],
deps = [
":todo",
"//packages/common",
"//packages/core",
"//packages/core/test/bundling/util:reflect_metadata",
"@npm//rxjs",
],
)
ts_library(
name = "test_lib",
testonly = True,
srcs = glob(["*_spec.ts"]),
tags = [
"ivy-only",
],
deps = [
"//packages:types",
"//packages/compiler",
"//packages/core",
"//packages/core/testing",
"//packages/private/testing",
],
)
jasmine_node_test(
name = "test",
data = [
":bundle",
":bundle.js",
build(ivy): support alternate compilation modes to enable Ivy testing (#24056) Bazel has a restriction that a single output (eg. a compiled version of //packages/common) can only be produced by a single rule. This precludes the Angular repo from having multiple rules that build the same code. And the complexity of having a single rule produce multiple outputs (eg. an ngc-compiled version of //packages/common and an Ivy-enabled version) is too high. Additionally, the Angular repo has lots of existing tests which could be executed as-is under Ivy. Such testing is very valuable, and it would be nice to share not only the code, but the dependency graph / build config as well. Thus, this change introduces a --define flag 'compile' with three potential values. When --define=compile=X is set, the entire build system runs in a particular mode - the behavior of all existing targets is controlled by the flag. This allows us to reuse our entire build structure for testing in a variety of different manners. The flag has three possible settings: * legacy (the default): the traditional View Engine (ngc) build * local: runs the prototype ngtsc compiler, which does not rely on global analysis * jit: runs ngtsc in a mode which executes tsickle, but excludes the Angular related transforms, which approximates the behavior of plain tsc. This allows the main packages such as common to be tested with the JIT compiler. Additionally, the ivy_ng_module() rule still exists and runs ngc in a mode where Ivy-compiled output is produced from global analysis information, as a stopgap while ngtsc is being developed. PR Close #24056
2018-05-21 18:48:00 -04:00
":bundle.min.js",
":bundle.min_debug.js",
],
tags = [
"ivy-only",
],
deps = [":test_lib"],
)
js_expected_symbol_test(
name = "symbol_test",
src = ":bundle.min_debug.js",
golden = ":bundle.golden_symbols.json",
tags = [
"ivy-aot",
"ivy-only",
],
)
genrule(
name = "tslib",
srcs = [
"@npm//:node_modules/tslib/tslib.js",
],
outs = [
"tslib.js",
],
cmd = "cp $< $@",
tags = [
"ivy-only",
],
)
ts_devserver(
name = "devserver",
entry_module = "@angular/core/test/bundling/todo",
scripts = [
"//tools/rxjs:rxjs_umd_modules",
],
# Use a serving_path that matches the common static index.html used
# in both devserver & prodserver
serving_path = "/bundle.min.js.br",
static_files = [
"index.html",
":tslib",
"todo.css",
"base.css",
],
tags = [
"ivy-only",
],
deps = [":todo"],
)
http_server(
name = "prodserver",
data = [
"base.css",
"index.html",
"todo.css",
":bundle.min.js.br",
":bundle.min_debug.js",
],
tags = [
"ivy-only",
],
)