Skip to content

Commit a60e650

Browse files
devversionzarend
authored andcommitted
build: make custom devserver work with e2e tests
For APF v13, we will switch to the custom devserver we have used for the dev-app as well. We do this because the ConcatJS devserver is no longer needed due to us bundling the e2e-app. Note again: This is needed because FW packages do no longer ship UMD files, and we also need to consolidate our pre-built linker ESM bundles of the Angular framework packages. A bundler like ESBuild will do that job for us. It's fast enough that it's subjectively significantly faster than ConcatJS/RequireJS resolving deps at runtime in the browser..
1 parent 3929979 commit a60e650

File tree

4 files changed

+10
-12
lines changed

4 files changed

+10
-12
lines changed

src/e2e-app/start-devserver.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const utils = require('@bazel/protractor/protractor-utils.js');
1010
* starting up the devserver and updating the Protractor base URL to the proper port.
1111
*/
1212
module.exports = async function(config) {
13-
const {port} = await utils.runServer(config.workspace, config.server, '-port', []);
13+
const {port} = await utils.runServer(config.workspace, config.server, '--port', []);
1414
const baseUrl = `http://localhost:${port}`;
1515
const processedConfig = await protractor.browser.getProcessedConfig();
1616

tools/dev-server/ibazel.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ const ibazelNotifySuccessMessage = 'IBAZEL_BUILD_COMPLETED SUCCESS';
1818
* over "stdin", the devserver can be reloaded.
1919
*/
2020
export function setupBazelWatcherSupport(server: DevServer) {
21+
// If iBazel is not configured for this process, we do not setup the watcher.
22+
if (process.env['IBAZEL_NOTIFY_CHANGES'] !== 'y') {
23+
return;
24+
}
25+
2126
// ibazel communicates via the stdin interface.
2227
const rl = createInterface({input: process.stdin, terminal: false});
2328

tools/dev-server/index.bzl

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ def _dev_server_rule_impl(ctx):
4141
# into a string representing the command line arguments. It looks like bazel has some
4242
# internal logic to compute the string representation of "ctx.actions.args()".
4343
args = '--root_paths="%s" ' % ",".join(root_paths)
44-
args += "--port=%s " % ctx.attr.port
4544

4645
if ctx.attr.historyApiFallback:
4746
args += "--historyApiFallback "
@@ -87,10 +86,6 @@ dev_server_rule = rule(
8786
This is helpful for single page applications using the HTML history API.
8887
""",
8988
),
90-
"port": attr.int(
91-
default = 4200,
92-
doc = """The port that the devserver will listen on.""",
93-
),
9489
"srcs": attr.label_list(allow_files = True, doc = """
9590
Sources that should be available to the dev-server. This attribute can be
9691
used for explicit files. This attribute only uses the files exposed by the
@@ -110,11 +105,12 @@ dev_server_rule = rule(
110105
request files through their manifest path: "my_workspace/src/dev-app/my-genfile".
111106
"""
112107

113-
def dev_server(name, testonly = False, tags = [], **kwargs):
108+
def dev_server(name, testonly = False, port = 4200, tags = [], **kwargs):
114109
dev_server_rule(
115110
name = "%s_launcher" % name,
116111
visibility = ["//visibility:private"],
117112
tags = tags,
113+
testonly = testonly,
118114
**kwargs
119115
)
120116

@@ -125,5 +121,6 @@ def dev_server(name, testonly = False, tags = [], **kwargs):
125121
tags = tags + ["ibazel_notify_changes"],
126122
srcs = ["%s_launcher.sh" % name],
127123
data = [":%s_launcher" % name],
124+
args = ["--port=%s" % port],
128125
testonly = testonly,
129126
)

tools/dev-server/launcher_template.sh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/
1414
{ echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e
1515
# --- end runfiles.bash initialization v2 ---
1616

17-
if [[ ! -z "RUNFILES_DIR" ]]; then
18-
export RUNFILES_MANIFEST_ONLY="1"
19-
fi
20-
2117
# Resolve the path of the dev-server binary. Note: usually we either need to
2218
# resolve the "nodejs_binary" executable with different file extensions on
2319
# windows, but since we already run this launcher as part of a "sh_binary", we
@@ -26,4 +22,4 @@ devserverBin=$(rlocation "angular_material/tools/dev-server/dev-server_bin.sh")
2622

2723
# Start the devserver with the given arguments. The arguments will be
2824
# substituted based on the rule attributes.
29-
${devserverBin} TEMPLATED_args
25+
${devserverBin} TEMPLATED_args "$@"

0 commit comments

Comments
 (0)