2018-01-09 18:24:00 -05:00
|
|
|
"""Re-export of some bazel rules with repository-wide defaults."""
|
2018-08-07 19:15:45 -04:00
|
|
|
|
2018-03-13 14:00:53 -04:00
|
|
|
load("@build_bazel_rules_nodejs//:defs.bzl", _npm_package = "npm_package")
|
2018-05-11 12:43:06 -04:00
|
|
|
load("@build_bazel_rules_typescript//:defs.bzl", _ts_library = "ts_library", _ts_web_test_suite = "ts_web_test_suite")
|
2018-02-13 14:26:06 -05:00
|
|
|
load("//packages/bazel:index.bzl", _ng_module = "ng_module", _ng_package = "ng_package")
|
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
|
|
|
load("//packages/bazel/src:ng_module.bzl", _internal_global_ng_module = "internal_global_ng_module")
|
2018-01-09 18:24:00 -05:00
|
|
|
|
|
|
|
DEFAULT_TSCONFIG = "//packages:tsconfig-build.json"
|
2018-06-25 14:22:23 -04:00
|
|
|
DEFAULT_NODE_MODULES = "@angular_deps//:node_modules"
|
2018-01-09 18:24:00 -05:00
|
|
|
|
2018-03-13 14:00:53 -04:00
|
|
|
# Packages which are versioned together on npm
|
|
|
|
ANGULAR_SCOPED_PACKAGES = ["@angular/%s" % p for p in [
|
2018-08-07 19:15:45 -04:00
|
|
|
# core should be the first package because it's the main package in the group
|
|
|
|
# this is significant for Angular CLI and "ng update" specifically, @angular/core
|
|
|
|
# is considered the identifier of the group by these tools.
|
|
|
|
"core",
|
|
|
|
"bazel",
|
|
|
|
"common",
|
|
|
|
"compiler",
|
|
|
|
"compiler-cli",
|
|
|
|
"animations",
|
|
|
|
"elements",
|
|
|
|
"platform-browser",
|
|
|
|
"platform-browser-dynamic",
|
|
|
|
"forms",
|
|
|
|
"http",
|
|
|
|
"platform-server",
|
|
|
|
"platform-webworker",
|
|
|
|
"platform-webworker-dynamic",
|
|
|
|
"upgrade",
|
|
|
|
"router",
|
|
|
|
"language-service",
|
|
|
|
"service-worker",
|
2018-03-13 14:00:53 -04:00
|
|
|
]]
|
|
|
|
|
|
|
|
PKG_GROUP_REPLACEMENTS = {
|
|
|
|
"\"NG_UPDATE_PACKAGE_GROUP\"": """[
|
|
|
|
%s
|
2018-08-07 19:15:45 -04:00
|
|
|
]""" % ",\n ".join(["\"%s\"" % s for s in ANGULAR_SCOPED_PACKAGES]),
|
2018-03-13 14:00:53 -04:00
|
|
|
}
|
|
|
|
|
2018-06-25 14:22:23 -04:00
|
|
|
def ts_library(tsconfig = None, node_modules = DEFAULT_NODE_MODULES, **kwargs):
|
2018-08-07 19:15:45 -04:00
|
|
|
if not tsconfig:
|
|
|
|
tsconfig = DEFAULT_TSCONFIG
|
|
|
|
_ts_library(tsconfig = tsconfig, node_modules = node_modules, **kwargs)
|
2018-01-09 18:24:00 -05:00
|
|
|
|
2018-06-25 14:22:23 -04:00
|
|
|
def ng_module(name, tsconfig = None, entry_point = None, node_modules = DEFAULT_NODE_MODULES, **kwargs):
|
2018-08-07 19:15:45 -04:00
|
|
|
if not tsconfig:
|
|
|
|
tsconfig = DEFAULT_TSCONFIG
|
|
|
|
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)
|
2018-02-13 14:26:06 -05:00
|
|
|
|
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
|
|
|
# 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):
|
2018-08-07 19:15:45 -04:00
|
|
|
if not tsconfig:
|
|
|
|
tsconfig = DEFAULT_TSCONFIG
|
|
|
|
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)
|
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
|
|
|
|
2018-04-12 20:43:27 -04:00
|
|
|
def ng_package(name, readme_md = None, license_banner = None, **kwargs):
|
2018-08-07 19:15:45 -04:00
|
|
|
if not readme_md:
|
|
|
|
readme_md = "//packages:README.md"
|
|
|
|
if not license_banner:
|
|
|
|
license_banner = "//packages:license-banner.txt"
|
2018-02-13 14:26:06 -05:00
|
|
|
|
2018-08-07 19:15:45 -04:00
|
|
|
_ng_package(
|
|
|
|
name = name,
|
|
|
|
readme_md = readme_md,
|
|
|
|
license_banner = license_banner,
|
|
|
|
replacements = PKG_GROUP_REPLACEMENTS,
|
|
|
|
**kwargs
|
|
|
|
)
|
2018-03-13 14:00:53 -04:00
|
|
|
|
|
|
|
def npm_package(name, replacements = {}, **kwargs):
|
2018-08-07 19:15:45 -04:00
|
|
|
_npm_package(
|
|
|
|
name = name,
|
|
|
|
replacements = dict(replacements, **PKG_GROUP_REPLACEMENTS),
|
|
|
|
**kwargs
|
|
|
|
)
|
2018-03-15 21:33:52 -04:00
|
|
|
|
2018-05-11 12:43:06 -04:00
|
|
|
def ts_web_test_suite(bootstrap = [], deps = [], **kwargs):
|
2018-08-07 19:15:45 -04:00
|
|
|
if not bootstrap:
|
|
|
|
bootstrap = ["//:web_test_bootstrap_scripts"]
|
|
|
|
local_deps = [
|
|
|
|
"@angular_deps//:node_modules/tslib/tslib.js",
|
|
|
|
"//tools/testing:browser",
|
|
|
|
] + deps
|
2018-03-15 21:33:52 -04:00
|
|
|
|
2018-08-07 19:15:45 -04:00
|
|
|
_ts_web_test_suite(
|
|
|
|
bootstrap = bootstrap,
|
|
|
|
deps = local_deps,
|
|
|
|
# Run unit tests on local Chromium by default.
|
|
|
|
# You can exclude tests based on tags, e.g. to skip Firefox testing,
|
|
|
|
# `bazel test --test_tag_filters=-browser:firefox-local [targets]`
|
|
|
|
browsers = [
|
|
|
|
"@io_bazel_rules_webtesting//browsers:chromium-local",
|
|
|
|
# Don't test on local Firefox by default, for faster builds.
|
|
|
|
# We think that bugs in Angular tend to be caught the same in any
|
|
|
|
# evergreen browser.
|
|
|
|
# "@io_bazel_rules_webtesting//browsers:firefox-local",
|
|
|
|
# TODO(alexeagle): add remote browsers on SauceLabs
|
|
|
|
],
|
|
|
|
**kwargs
|
|
|
|
)
|