Rollup just prints a warning if an import cannot be resolved and ends up being treated as an external dependency. This in combination with the `silent = True` attribute for `rollup_bundle` means that bundles might end up being extremely small without people noticing that it misses actual imports. To improve this situation, the warning is replaced by an error if an import cannot be resolved. This unveiles an issue with the `ng_rollup_bundle` macro from dev-infra where imports in View Engine were not resolved but ended up being treated as external. This did not prevent benchmarks using this macro from working because the ConcatJS devserver had builtin resolution for workspace manifest paths. Though given the new check for no unresolved imports, this will now cause errors within Rollup, and we need to fix the resolution. We can fix the issue by temporarily enabling workspace linking. This does not have any performance downsides. To enable workspace linking (which we might need more often in the future given the linker taking over patched module resolution), we had to rename the `angular` dependency to a more specific one so that the Angular linker could link into `node_modules/angular`. PR Close #42760
70 lines
2.2 KiB
Python
70 lines
2.2 KiB
Python
load("//tools:defaults.bzl", "ng_module", "protractor_web_test_suite", "ts_devserver", "ts_library")
|
|
|
|
"""
|
|
Macro that can be used to create the Bazel targets for an "upgrade" example. Since the
|
|
upgrade examples bootstrap their application manually, and we cannot serve all examples,
|
|
we need to define the devserver for each example. This macro reduces code duplication
|
|
for defining these targets.
|
|
"""
|
|
|
|
def create_upgrade_example_targets(name, srcs, e2e_srcs, entry_module, assets = []):
|
|
ng_module(
|
|
name = "%s_sources" % name,
|
|
srcs = srcs,
|
|
generate_ve_shims = True,
|
|
deps = [
|
|
"@npm//@types/angular",
|
|
"@npm//@types/jasmine",
|
|
"//packages/core",
|
|
"//packages/platform-browser",
|
|
"//packages/platform-browser-dynamic",
|
|
"//packages/upgrade/static",
|
|
"//packages/core/testing",
|
|
"//packages/upgrade/static/testing",
|
|
],
|
|
tsconfig = "//packages/examples/upgrade:tsconfig-build.json",
|
|
)
|
|
|
|
ts_library(
|
|
name = "%s_e2e_lib" % name,
|
|
srcs = e2e_srcs,
|
|
testonly = True,
|
|
deps = [
|
|
"@npm//@types/jasminewd2",
|
|
"@npm//protractor",
|
|
"//packages/examples/test-utils",
|
|
"//packages/private/testing",
|
|
],
|
|
tsconfig = "//packages/examples:tsconfig-e2e.json",
|
|
)
|
|
|
|
ts_devserver(
|
|
name = "devserver",
|
|
port = 4200,
|
|
entry_module = entry_module,
|
|
additional_root_paths = ["angular/packages/examples"],
|
|
bootstrap = [
|
|
"//packages/zone.js/bundles:zone.umd.js",
|
|
"@npm//:node_modules/angular-1.8/angular.js",
|
|
"@npm//:node_modules/reflect-metadata/Reflect.js",
|
|
],
|
|
static_files = [
|
|
"//packages/examples:index.html",
|
|
] + assets,
|
|
scripts = [
|
|
"@npm//:node_modules/tslib/tslib.js",
|
|
"//tools/rxjs:rxjs_umd_modules",
|
|
],
|
|
deps = [":%s_sources" % name],
|
|
)
|
|
|
|
protractor_web_test_suite(
|
|
name = "%s_protractor" % name,
|
|
on_prepare = "//packages/examples/upgrade:start-server.js",
|
|
server = ":devserver",
|
|
deps = [
|
|
":%s_e2e_lib" % name,
|
|
"@npm//selenium-webdriver",
|
|
],
|
|
)
|