Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

Commit 3d38e11

Browse files
committed
Add workaround for specifying serving_path on windows.
1 parent fa6b790 commit 3d38e11

File tree

6 files changed

+23
-18
lines changed

6 files changed

+23
-18
lines changed

devserver/main.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ func main() {
4545
os.Exit(1)
4646
}
4747

48+
if !strings.HasPrefix(*servingPath, "/") {
49+
fmt.Fprintf(os.Stderr, "The specified serving_path does not start with a slash. " +
50+
"This causes the serving path to not have any effect.\n")
51+
os.Exit(1)
52+
}
53+
4854
preScripts := make([]string, 0, 100)
4955
postScripts := make([]string, 0, 1)
5056

examples/protocol_buffers/BUILD.bazel

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ ts_devserver(
6161
entry_module = "build_bazel_rules_typescript/examples/protocol_buffers/app",
6262
port = 8080,
6363
deps = [":bundle"],
64-
static_files = [":index.html"],
65-
serving_path = "/concatjs-bundle.js",
6664
)
6765

6866
# Test for production mode

examples/protocol_buffers/index.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
<title>protocol_buffers example</title>
44
</head>
55
<body>
6-
<script src="/concatjs-bundle.js"></script>
6+
<script src="/protobuf.min.js"></script>
7+
<script src="/long.js"></script>
8+
<script src="/bundle.min.js"></script>
79
</body>
810
</html>

internal/devserver/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ package(default_visibility = [
2222

2323
exports_files([
2424
"ts_devserver.bzl", # Exported to be consumed for generating skydoc.
25-
"devserver_launcher.sh",
25+
"launcher_template.sh",
2626
])
2727

2828
filegroup(

internal/devserver/devserver_launcher.sh renamed to internal/devserver/launcher_template.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
#!/bin/sh
2-
# Copyright 2017 The Bazel Authors. All rights reserved.
1+
#!/bin/bash
2+
3+
# Copyright 2018 The Bazel Authors. All rights reserved.
34
#
45
# Licensed under the Apache License, Version 2.0 (the "License");
56
# you may not use this file except in compliance with the License.
@@ -47,7 +48,9 @@ readonly manifest=$(rlocation "TEMPLATED_workspace/TEMPLATED_manifest")
4748
readonly scripts_manifest=$(rlocation "TEMPLATED_workspace/TEMPLATED_scripts_manifest")
4849
readonly entry_module=$(rlocation "TEMPLATED_entry_module")
4950

50-
"${main}" \
51+
# Workaround for https://github.com/bazelbuild/bazel/issues/6764
52+
# If this issue is incorporated into Bazel, the workaround here should be removed.
53+
MSYS2_ARG_CONV_EXCL="*" "${main}" \
5154
-packages=TEMPLATED_packages \
5255
-serving_path=TEMPLATED_serving_path \
5356
-manifest="${manifest}" \

internal/devserver/ts_devserver.bzl

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,14 @@ def _ts_devserver(ctx):
111111
])
112112

113113
substitutions = {
114+
"TEMPLATED_entry_module": ctx.attr.entry_module,
114115
"TEMPLATED_main": script_path,
115-
"TEMPLATED_workspace": workspace_name,
116-
"TEMPLATED_packages": ",".join(packages.to_list()),
117-
"TEMPLATED_serving_path": ctx.attr.serving_path if ctx.attr.serving_path else "",
118116
"TEMPLATED_manifest": ctx.outputs.manifest.short_path,
119-
"TEMPLATED_scripts_manifest": ctx.outputs.scripts_manifest.short_path,
120-
"TEMPLATED_entry_module": ctx.attr.entry_module,
117+
"TEMPLATED_packages": ",".join(packages.to_list()),
121118
"TEMPLATED_port": str(ctx.attr.port),
119+
"TEMPLATED_scripts_manifest": ctx.outputs.scripts_manifest.short_path,
120+
"TEMPLATED_serving_path": ctx.attr.serving_path if ctx.attr.serving_path else "",
121+
"TEMPLATED_workspace": workspace_name,
122122
}
123123
ctx.actions.expand_template(
124124
template=ctx.file._launcher_template,
@@ -207,17 +207,13 @@ ts_devserver = rule(
207207
executable = True,
208208
cfg = "host",
209209
),
210+
"_launcher_template": attr.label(allow_single_file = True, default = Label("//internal/devserver:launcher_template.sh")),
210211
"_requirejs_script": attr.label(allow_single_file = True, default = Label("@build_bazel_rules_typescript_devserver_deps//node_modules/requirejs:require.js")),
211-
"_launcher_template": attr.label(
212-
default = Label("//internal/devserver:devserver_launcher.sh"),
213-
allow_files = True,
214-
single_file = True
215-
),
216212
},
217213
outputs = {
218214
"manifest": "%{name}.MF",
219-
"scripts_manifest": "scripts_%{name}.MF",
220215
"script": "%{name}.sh",
216+
"scripts_manifest": "scripts_%{name}.MF",
221217
},
222218
executable = True,
223219
)

0 commit comments

Comments
 (0)