2022-06-20 19:41:03 +00:00
|
|
|
# Re-export of Bazel rules with devtools-wide defaults
|
2021-11-07 23:57:52 +00:00
|
|
|
|
2022-07-27 08:03:49 +00:00
|
|
|
load("@npm//@angular/build-tooling/bazel/spec-bundling:index.bzl", "spec_bundle")
|
|
|
|
|
load("@npm//@angular/build-tooling/bazel/karma:index.bzl", _karma_web_test_suite = "karma_web_test_suite")
|
|
|
|
|
load("@npm//@angular/build-tooling/bazel:extract_js_module_output.bzl", "extract_js_module_output")
|
2021-12-16 07:00:43 +00:00
|
|
|
|
2021-11-07 23:57:52 +00:00
|
|
|
def karma_web_test_suite(name, **kwargs):
|
|
|
|
|
test_deps = kwargs.get("deps", [])
|
|
|
|
|
kwargs["deps"] = ["%s_bundle" % name]
|
|
|
|
|
|
2022-06-20 19:41:03 +00:00
|
|
|
# TODO(ESM): Remove this when devmode & prodmode are combined.
|
|
|
|
|
extract_js_module_output(
|
|
|
|
|
name = "%s_prodmode_deps" % name,
|
|
|
|
|
deps = test_deps,
|
|
|
|
|
provider = "JSEcmaScriptModuleInfo",
|
|
|
|
|
forward_linker_mappings = True,
|
|
|
|
|
include_external_npm_packages = True,
|
|
|
|
|
include_default_files = False,
|
|
|
|
|
include_declarations = True,
|
|
|
|
|
testonly = True,
|
|
|
|
|
)
|
|
|
|
|
|
2021-11-07 23:57:52 +00:00
|
|
|
spec_bundle(
|
|
|
|
|
name = "%s_bundle" % name,
|
2022-06-20 19:41:03 +00:00
|
|
|
deps = ["%s_prodmode_deps" % name],
|
2021-11-07 23:57:52 +00:00
|
|
|
platform = "browser",
|
2022-06-20 19:41:03 +00:00
|
|
|
run_angular_linker = True,
|
|
|
|
|
# We consume the Angular framework packages directly from source. The
|
|
|
|
|
# placeholders might not be substituted and still use `0.0.0-PLACEHOLDER`.
|
|
|
|
|
linker_unknown_declaration_handling = "ignore",
|
|
|
|
|
workspace_name = "angular",
|
2021-11-07 23:57:52 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Set up default browsers if no explicit `browsers` have been specified.
|
|
|
|
|
if not hasattr(kwargs, "browsers"):
|
|
|
|
|
kwargs["tags"] = ["native"] + kwargs.get("tags", [])
|
|
|
|
|
kwargs["browsers"] = [
|
2022-07-27 08:03:49 +00:00
|
|
|
"@npm//@angular/build-tooling/bazel/browsers/chromium:chromium",
|
2021-12-01 02:51:06 +00:00
|
|
|
|
|
|
|
|
# todo(aleksanderbodurri): enable when firefox support is done
|
2022-07-27 08:03:49 +00:00
|
|
|
# "@npm//@angular/build-tooling/bazel/browsers/firefox:firefox",
|
2021-11-07 23:57:52 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
# Default test suite with all configured browsers.
|
|
|
|
|
_karma_web_test_suite(
|
|
|
|
|
name = name,
|
2021-12-16 07:00:43 +00:00
|
|
|
bootstrap = [
|
|
|
|
|
"@npm//:node_modules/tslib/tslib.js",
|
|
|
|
|
],
|
2021-11-07 23:57:52 +00:00
|
|
|
**kwargs
|
|
|
|
|
)
|