-
Notifications
You must be signed in to change notification settings - Fork 522
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(typescript): fix for cross platform ts_devserver issue #1409 #1413
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ load( | |
"@build_bazel_rules_nodejs//internal/js_library:js_library.bzl", | ||
"write_amd_names_shim", | ||
) | ||
load("@nodejs//:index.bzl", "host_platform") | ||
|
||
# Avoid using non-normalized paths (workspace/../other_workspace/path) | ||
def _to_manifest_path(ctx, file): | ||
|
@@ -86,8 +87,14 @@ def _ts_devserver(ctx): | |
for f in script_files | ||
])) | ||
|
||
# With cross-platform RBE for OSX & Windows ctx.executable.devserver will be linux as --cpu and | ||
# --host_cpu must be overridden to k8. However, we still want to be able to run the devserver on the host | ||
# machine so we need to include the host devserver binary, which is ctx.executable.devserver_host, in the | ||
# runfiles. For non-RBE and for RBE with a linux host, ctx.executable.devserver & ctx.executable.devserver_host | ||
# will be the same binary. | ||
devserver_runfiles = [ | ||
ctx.executable.devserver, | ||
ctx.executable.devserver_host, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. feels really gross to upload both binaries to RBE just because it can't select the right one. This is a limitation of cross-platform RBE being broken? Still feels like a hacky workaround There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess you mean this one: https://github.com/bazelbuild/rules_nodejs/blob/dcdc98b093edf2a3ccd6962d8b4f15aa28ba6fa8/internal/common/windows_utils.bzl#L63 It's basically a hack to make the code simpler, but it should work. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm we also need a way to distinguish mac from linux, do you know of any trick to do that? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, maybe you can consider this: Adding the following to .bazelrc
Then you can check the value of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that's clever but we can't control users' .bazelrc files so this will get us in trouble |
||
ctx.outputs.manifest, | ||
ctx.outputs.scripts_manifest, | ||
] | ||
|
@@ -138,11 +145,25 @@ ts_devserver = rule( | |
), | ||
"devserver": attr.label( | ||
doc = """Go based devserver executable. | ||
|
||
With cross-platform RBE for OSX & Windows ctx.executable.devserver will be linux as --cpu and | ||
--host_cpu must be overridden to k8. However, we still want to be able to run the devserver on the host | ||
machine so we need to include the host devserver binary, which is ctx.executable.devserver_host, in the | ||
runfiles. For non-RBE and for RBE with a linux host, ctx.executable.devserver & ctx.executable.devserver_host | ||
will be the same binary. | ||
|
||
Defaults to precompiled go binary in @npm_bazel_typescript setup by @bazel/typescript npm package""", | ||
default = Label("//devserver"), | ||
executable = True, | ||
cfg = "host", | ||
), | ||
"devserver_host": attr.label( | ||
doc = """Go based devserver executable for the host platform. | ||
Defaults to precompiled go binary in @npm_bazel_typescript setup by @bazel/typescript npm package""", | ||
default = Label("//devserver:devserver_%s" % host_platform), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is there some other way we could get this info so we don't need to create the new index.bzl file and make the rollout complicated? @meteorcloudy maybe you have some idea - I know there's a starlark trick to know if we are on Windows or not |
||
executable = True, | ||
cfg = "host", | ||
), | ||
"entry_module": attr.string( | ||
doc = """The `entry_module` should be the AMD module name of the entry module such as `"__main__/src/index".` | ||
`ts_devserver` concats the following snippet after the bundle to load the application: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we could key this off the path to node instead?
This comment was marked as spam.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, sorry. I commented at the wrong place.