build: remove remaining usages of deprecated ts_devserver (#48521)

* Switches all remaining targets (even if not tested and failing as per
  build) away from `ts_devserver` to the canonical `http_server` from
  dev-infra.

PR Close #48521
This commit is contained in:
Paul Gschwendtner
2022-12-15 20:50:19 +00:00
parent 5c10efe002
commit 623ca1f787
13 changed files with 122 additions and 252 deletions
+7 -20
View File
@@ -1,4 +1,4 @@
load("//tools:defaults.bzl", "app_bundle", "ng_module", "ts_devserver")
load("//tools:defaults.bzl", "app_bundle", "http_server", "ng_module")
package(default_visibility = ["//modules/benchmarks:__subpackages__"])
@@ -25,27 +25,14 @@ app_bundle(
],
)
ts_devserver(
name = "prodserver",
static_files = [
http_server(
name = "server",
srcs = [
"index.html",
],
deps = [
":bundle.debug.min.js",
":bundle.min.js",
"//packages/zone.js/bundles:zone.umd.js",
"index.html",
],
)
ts_devserver(
name = "devserver",
entry_module = "angular/modules/benchmarks/src/views/index",
scripts = [
"@npm//:node_modules/tslib/tslib.js",
"//tools/rxjs:rxjs_umd_modules",
],
serving_path = "/index.js",
static_files = [
"//packages/zone.js/bundles:zone.umd.js",
"index.html",
],
deps = [":application_lib"],
)
+31 -31
View File
@@ -1,38 +1,38 @@
<!doctype html>
<!DOCTYPE html>
<html>
<head>
<!-- Prevent the browser from requesting any favicon. -->
<link rel="icon" href="data:," />
</head>
<head>
<!-- Prevent the browser from requesting any favicon. -->
<link rel="icon" href="data:,">
</head>
<body>
<h1>Views traversal benchmark</h1>
<body>
<benchmark-root>loading...</benchmark-root>
<h1>Views traversal benchmark</h1>
<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 alreadyBootstrapped = document.querySelectorAll('script').length > 1; // 1 for ourselves
if (!alreadyBootstrapped) {
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);
<script>
addEventListener('DOMContentLoaded', () => {
// DevServer has automatic bootstrap code, so if we already have <scripts> than we don't need to bootstrap
// two scripts are from Browserstack and this script tag.
var alreadyBootstrapped = document.querySelectorAll('script').length > 3;
if (!alreadyBootstrapped) {
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('/angular/packages/zone.js/bundles/zone.umd.js').then(function () {
loadScript(
document.location.search.endsWith('debug') ? 'bundle.debug.min.js' : 'bundle.min.js'
);
});
}
// zone.js must be loaded and processed before Angular bundle gets executed
loadScript('/npm/node_modules/zone.js/bundles/zone.umd.js').then(function () {
loadScript(document.location.search.endsWith('debug') ? 'bundle.debug.min.js' : 'bundle.min.js');
});
}
});
</script>
</body>
});
</script>
</body>
</html>
@@ -1,5 +1,4 @@
load("//tools:defaults.bzl", "app_bundle", "ng_module", "ts_devserver")
load("@npm//http-server:index.bzl", "http_server")
load("//tools:defaults.bzl", "app_bundle", "http_server", "ng_module")
package(default_visibility = ["//visibility:public"])
@@ -23,34 +22,15 @@ app_bundle(
],
)
ts_devserver(
name = "devserver",
additional_root_paths = [
"npm/node_modules/tslib",
],
entry_module = "@angular/core/test/bundling/animation_world",
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 = [
"animation_world.css",
"base.css",
"index.html",
"@npm//tslib",
],
deps = [":animation_world"],
)
http_server(
name = "prodserver",
data = [
name = "server",
srcs = [
"animation_world.css",
"base.css",
"index.html",
":bundle.debug.min.js",
":bundle.min.js",
],
deps = [
":bundle.debug.min",
":bundle.min.js.br",
],
)
@@ -1,15 +1,15 @@
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="base.css">
<link rel="stylesheet" href="animation_world.css">
<title>Angular Hello World Example</title>
</head>
<body>
<!-- The Angular application will be bootstrapped into this element. -->
<animation-world></animation-world>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="base.css" />
<link rel="stylesheet" href="animation_world.css" />
<title>Angular Hello World Example</title>
</head>
<body>
<!-- The Angular application will be bootstrapped into this element. -->
<animation-world></animation-world>
<!--
<!--
Script tag which bootstraps the application. Use `?debug` in URL to select
the debug version of the script.
@@ -23,10 +23,15 @@
plugins from the devkit and terser, however mangling is disabled and the minified
file is formatted using prettier (to ease debugging).
-->
<script>
document.write('<script src="' +
(document.location.search.endsWith('debug') ? '/bundle.debug.min.js' : '/bundle.min.js.br') +
'"></' + 'script>');
</script>
</body>
</html>
<script>
document.write(
'<script src="' +
(document.location.search.endsWith('debug')
? '/bundle.debug.min.js'
: '/bundle.min.js.br') +
'"></' +
'script>'
);
</script>
</body>
</html>
@@ -19,19 +19,6 @@ export async function collectBrowserLogs(
browserLog.forEach(logEntry => {
const msg = logEntry.message;
// Since we currently use the `ts_devserver` from the Bazel TypeScript rules, which does
// fallback to the "index.html" file for HTML5 pushState routing but does always serve the
// expected fallback with a 404 status code, the browser will print a message about the 404,
// while the page loaded properly. Ideally the "ts_devserver" would allow us to opt-in for
// just returning a 200 status code, but the devserver is intended to be kept manually, so
// we manually filter this error before ensuring there are no console errors.
// TODO: This is a current limitation of using the "ts_devserver" with Angular routing.
// Tracked with: TOOL-629
if (msg.includes(
`Failed to load resource: the server responded with a status of 404 (Not Found)`)) {
return;
}
console.log('>> ' + msg, logEntry);
if ((!collectMoreSevereErrors && logEntry.level.value === loggingLevel.value) ||
+6 -29
View File
@@ -1,6 +1,5 @@
load("//tools:defaults.bzl", "app_bundle", "jasmine_node_test", "ng_module", "ts_devserver", "ts_library")
load("//tools:defaults.bzl", "app_bundle", "http_server", "jasmine_node_test", "ng_module", "ts_library")
load("//tools/symbol-extractor:index.bzl", "js_expected_symbol_test")
load("@npm//http-server:index.bzl", "http_server")
package(default_visibility = ["//visibility:public"])
@@ -59,36 +58,14 @@ js_expected_symbol_test(
golden = ":bundle.golden_symbols.json",
)
genrule(
name = "tslib",
srcs = [
"@npm//:node_modules/tslib/tslib.js",
],
outs = [
"tslib.js",
],
cmd = "cp $< $@",
)
ts_devserver(
name = "devserver",
entry_module = "@angular/core/test/bundling/router",
scripts = [
"//tools/rxjs:rxjs_umd_modules",
],
serving_path = "/bundle.min.js",
static_files = [
"index.html",
":tslib",
],
deps = [":router"],
)
http_server(
name = "prodserver",
data = [
name = "server",
srcs = [
"index.html",
],
deps = [
":bundle.debug.min.js",
":bundle.min.js",
"//packages/zone.js/bundles:zone.umd.js",
],
)
@@ -1,4 +1,4 @@
<!doctype html>
<!DOCTYPE html>
<html>
<head>
@@ -9,6 +9,7 @@
<app-root></app-root>
<script src="/angular/packages/zone.js/bundles/zone.umd.js"></script>
<!--
Script tag which bootstraps the application. Use `?debug` in URL to select
the debug version of the script.
@@ -24,9 +25,12 @@
file is formatted using prettier (to ease debugging).
-->
<script>
document.write('<script src="' +
document.write(
'<script src="' +
(document.location.search.endsWith('debug') ? '/bundle.debug.min.js' : '/bundle.min.js') +
'"></' + 'script>');
'"></' +
'script>'
);
</script>
</body>
</html>
@@ -5,6 +5,7 @@
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {APP_BASE_HREF} from '@angular/common';
import {Component, OnInit} from '@angular/core';
import {bootstrapApplication} from '@angular/platform-browser';
+5 -33
View File
@@ -1,6 +1,5 @@
load("//tools:defaults.bzl", "app_bundle", "jasmine_node_test", "ng_module", "ts_devserver", "ts_library")
load("//tools:defaults.bzl", "app_bundle", "http_server", "jasmine_node_test", "ng_module", "ts_library")
load("//tools/symbol-extractor:index.bzl", "js_expected_symbol_test")
load("@npm//http-server:index.bzl", "http_server")
package(default_visibility = ["//visibility:public"])
@@ -62,41 +61,14 @@ js_expected_symbol_test(
golden = ":bundle.golden_symbols.json",
)
genrule(
name = "tslib",
srcs = [
"@npm//:node_modules/tslib/tslib.js",
],
outs = [
"tslib.js",
],
cmd = "cp $< $@",
)
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",
],
deps = [":todo"],
)
http_server(
name = "prodserver",
data = [
name = "server",
srcs = [
"base.css",
"index.html",
"todo.css",
],
deps = [
":bundle.debug.min.js",
":bundle.min.js.br",
],
+29 -23
View File
@@ -1,23 +1,22 @@
<!doctype html>
<!DOCTYPE html>
<html>
<head>
<title>Angular Todo Example</title>
<link rel="stylesheet" href="base.css" />
<link rel="stylesheet" href="todo.css" />
<style>
.done {
text-decoration: line-through;
}
</style>
</head>
<head>
<title>Angular Todo Example</title>
<link rel="stylesheet" href="base.css">
<link rel="stylesheet" href="todo.css">
<style>
.done {
text-decoration: line-through;
}
</style>
</head>
<body>
<!-- The Angular application will be bootstrapped into this element. -->
<todo-app></todo-app>
<body>
<!-- The Angular application will be bootstrapped into this element. -->
<todo-app></todo-app>
<!--
<!--
Script tag which bootstraps the application. Use `?debug` in URL to select
the debug version of the script.
@@ -31,11 +30,18 @@
plugins from the devkit and terser, however mangling is disabled and the minified
file is formatted using prettier (to ease debugging).
-->
<script>
document.write('<script src="' +
(document.location.search.endsWith('debug') ? '/bundle.debug.min.js' : '/bundle.min.js.br') +
'"></' + 'script>');
</script>
</body>
<script>
document.write(
'<script src="' +
(document.location.search.endsWith('debug')
? '/bundle.debug.min.js'
: '/bundle.min.js.br') +
'"></' +
'script>'
);
</script>
<script>
bootstrapApp();
</script>
</body>
</html>
@@ -1,5 +1,4 @@
load("//tools:defaults.bzl", "app_bundle", "jasmine_node_test", "ng_module", "ts_devserver", "ts_library")
load("@npm//http-server:index.bzl", "http_server")
load("//tools:defaults.bzl", "app_bundle", "http_server", "jasmine_node_test", "ng_module", "ts_library")
package(default_visibility = ["//visibility:public"])
@@ -56,41 +55,14 @@ jasmine_node_test(
deps = [":test_lib"],
)
genrule(
name = "tslib",
srcs = [
"@npm//:node_modules/tslib/tslib.js",
],
outs = [
"tslib.js",
],
cmd = "cp $< $@",
)
ts_devserver(
name = "devserver",
entry_module = "@angular/core/test/bundling/todo_i18n",
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",
],
deps = [":todo_i18n"],
)
http_server(
name = "prodserver",
data = [
name = "server",
srcs = [
"base.css",
"index.html",
"todo.css",
],
deps = [
":bundle.debug.min.js",
":bundle.min.js",
],
-13
View File
@@ -19,19 +19,6 @@ export async function verifyNoBrowserErrors() {
browserLog.forEach(logEntry => {
const msg = logEntry.message;
// Since we currently use the `ts_devserver` from the Bazel TypeScript rules, which does
// fallback to the "index.html" file for HTML5 pushState routing but does always serve the
// expected fallback with a 404 status code, the browser will print a message about the 404,
// while the page loaded properly. Ideally the "ts_devserver" would allow us to opt-in for
// just returning a 200 status code, but the devserver is intended to be kept manually, so
// we manually filter this error before ensuring there are no console errors.
// TODO: This is a current limitation of using the "ts_devserver" with Angular routing.
// Tracked with: TOOL-629
if (msg.includes(
`Failed to load resource: the server responded with a status of 404 (Not Found)`)) {
return;
}
console.log('>> ' + msg, logEntry);
if (logEntry.level.value >= logging.Level.INFO.value) {
+1 -9
View File
@@ -3,7 +3,7 @@
load("@rules_pkg//:pkg.bzl", "pkg_tar")
load("@build_bazel_rules_nodejs//:index.bzl", _npm_package_bin = "npm_package_bin", _pkg_npm = "pkg_npm")
load("@npm//@bazel/jasmine:index.bzl", _jasmine_node_test = "jasmine_node_test")
load("@npm//@bazel/concatjs:index.bzl", _concatjs_devserver = "concatjs_devserver", _ts_config = "ts_config", _ts_library = "ts_library")
load("@npm//@bazel/concatjs:index.bzl", _ts_config = "ts_config", _ts_library = "ts_library")
load("@npm//@bazel/rollup:index.bzl", _rollup_bundle = "rollup_bundle")
load("@npm//@bazel/terser:index.bzl", "terser_minified")
load("@npm//@bazel/protractor:index.bzl", _protractor_web_test_suite = "protractor_web_test_suite")
@@ -95,14 +95,6 @@ def _default_module_name(testonly):
return None
def ts_devserver(**kwargs):
"""Default values for ts_devserver"""
serving_path = kwargs.pop("serving_path", "/app_bundle.js")
_concatjs_devserver(
serving_path = serving_path,
**kwargs
)
ts_config = _ts_config
def ts_library(