test: make expanding_rows test work in g3 (#32568)

This PR modifies the `expanding_rows` test so that it works in g3.

1. `index,ts` must be named `index_aot.ts`
2. Scripts should be loaded via `ts_devserver` and not as an explicit
script tag in the HTML.

PR Close #32568
This commit is contained in:
Keen Yee Liau 2019-09-09 17:34:09 -07:00 committed by Matias Niemelä
parent 6ccb4e0bab
commit a813ae07e2
3 changed files with 14 additions and 32 deletions

View File

@ -32,7 +32,7 @@ ts_library(
ng_rollup_bundle( ng_rollup_bundle(
name = "bundle", name = "bundle",
entry_point = ":index.ts", entry_point = ":index_aot.ts",
deps = [ deps = [
":application_lib", ":application_lib",
"@npm//rxjs", "@npm//rxjs",
@ -41,26 +41,30 @@ ng_rollup_bundle(
ts_devserver( ts_devserver(
name = "prodserver", name = "prodserver",
index_html = "index.html",
port = 4200,
static_files = [ static_files = [
":bundle.min_debug.js",
":bundle.min.js",
"@npm//:node_modules/zone.js/dist/zone.js", "@npm//:node_modules/zone.js/dist/zone.js",
"index.html", ],
deps = [
":bundle.min.js",
], ],
) )
ts_devserver( ts_devserver(
name = "devserver", name = "devserver",
entry_module = "angular/modules/benchmarks/src/expanding_rows/index", entry_module = "angular/modules/benchmarks/src/expanding_rows/index_aot",
index_html = "index.html", # Uncomment this to run devserver. This is due to limitation of ts_devserver
# that produces `index.html` by default so there cannot be two ts_devserver
# rules in a single Bazel package.
# index_html = "index.html",
port = 4200,
scripts = [ scripts = [
"@npm//:node_modules/tslib/tslib.js", "@npm//:node_modules/tslib/tslib.js",
"//tools/rxjs:rxjs_umd_modules", "//tools/rxjs:rxjs_umd_modules",
], ],
serving_path = "/index.js",
static_files = [ static_files = [
"@npm//:node_modules/zone.js/dist/zone.js", "@npm//:node_modules/zone.js/dist/zone.js",
"index.html",
], ],
deps = [":application_lib"], deps = [":application_lib"],
) )

View File

@ -11,29 +11,7 @@
<h1>Change Detection Benchmark</h1> <h1>Change Detection Benchmark</h1>
<div id="rendererMode">...</div> <div id="rendererMode">...</div>
<benchmark-root>loading...</benchmark-root> <benchmark-root>Loading...</benchmark-root>
<script>
addEventListener('DOMContentLoaded', () => {
// DevServer has automatic bootstrap code, so if we already have <scripts> than we don't need to bootstrap
var alreadyBootstraped = document.querySelectorAll('script').length > 1; // 1 for ourselves
if (!alreadyBootstraped) {
function loadScript(url) {
return new Promise(function (resolve, reject) {
var script = document.createElement('script');
script.src = url;
script.onload = resolve;
script.onerror = reject;
document.body.append(script);
});
}
// zone.js must be loaded and processed before Angular bundle gets executed
loadScript('/npm/node_modules/zone.js/dist/zone.js').then(function () {
loadScript(document.location.search.endsWith('debug') ? 'bundle.min_debug.js' : 'bundle.min.js');
});
}
});
</script>
</body> </body>
</html> </html>