-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Input handling is based solely on TTY detection #5724
Comments
This is inherited behavior from legacy |
This isn't what happens with the @swc/cli wrapper though. We currently use that under Bazel and always pass files/directories in the command line arguments. It either does detect a TTY or follows some other codepath? |
Yes, there are some behavioral differences due to how rust detects stdin. Just saying why the current code works in this way. In any case, I agree we'd like to change current behavior. |
I'm trying to decide if we should
What do you think? Do you expect it will take a while to agree on what change is desired here? |
I think upstream will eventually pick 3, but I can't promise when, unfortunately. For the design I wouldn't expect we'll take too long though. Probably I'll accept some breaking changes, or even taking out stdin support as stdin usecase was quite thin anyway. |
Thanks OJ - FWIW I was able to use So perhaps I'll just include a hermetic compilation for socat and make that part of our swc toolchain in the case where we minify a directory, in case it takes a long time to resolve this. |
I think this was fixed in #6714 |
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Describe the bug
#5017 mentions the problem, but jumps into a big refactoring and has stalled. I'll try to distill the problem.
This bit of code
swc/bindings/swc_cli/src/commands/compile.rs
Lines 241 to 254 in 7a6a435
returns input from stdin purely based on a syscall to Rust's TTY detection.
Then this is handled non-conditionally where it returns:
swc/bindings/swc_cli/src/commands/compile.rs
Lines 296 to 299 in 7a6a435
Which means that if
swc
does not detect a TTY, you are forced to pass input on stdin.This is especially bad when you want to provide a directory of files as the inputs. There's no way to do this with the pure rust "swcx" binary.
(Bazel runs actions in a hermetic environment, or sometimes remotely on a farm of workers, and there is no TTY present)
Expected behavior
There ought to be some flag or environment variable the pure rust CLI can use to determine when to read input from stdin.
To make it simple and non-breaking, I'm not expecting a behavior change by default, just some affordance for tooling like Bazel to choose the codepath where inputs (in particular, a folder) can be passed as an argument to swc.
Version
1.2.246
The text was updated successfully, but these errors were encountered: