watch mode breaks stdout / piping
Bug description
When using watch mode, piping stdout is broken, it doesn't do anything at all, just prints straight to console. It works without watch.
- Before

- After (screen is cleared)

Reproduction
I can't do this without dependencies, ultimately my example is piping into one.
Environment
System:
OS: Windows 10 10.0.22621
CPU: (12) x64 AMD Ryzen 5 5500U with Radeon Graphics
Memory: 1.12 GB / 15.37 GB
Binaries:
Node: 18.8.0 - C:\Program Files\nodejs\node.EXE
npm: 9.2.0 - C:\Program Files\nodejs\npm.CMD
npmPackages:
tsx: ^3.12.2 => 3.12.2
Can you work on a fix?
- [ ] I’m interested in opening a pull request to address this issue.
I can't do this without dependencies, ultimately my example is piping into one.
That's fine if you can strip it down to bare minimums. Please provide a link to a minimal reproduction repository.
https://github.com/Nicholaiii/tsx-pipe
I am now only getting this issue on the first log line. I have no idea what (if anything) changed.
npm run normal (works immediately)
npm run watch (works after first log)
Same thing is happening when using concurrently to run tsx watch, no console output at all.
@piotrek-szczygiel
Thanks for your comment! But, with the limited info provided, I'm not sure if it's relevant to this thread, so I'm gonna hide it for now.
If you can share more details and steps to reproduce in a new Issue, that would be super helpful. Thanks, and let me know if you need any help.
@privatenumber I have the same problem too
I run npx tsx watch src/intex.ts | jg but the output from the program isn't parsable by jq and I get parse error: Invalid numeric literal at line 1, column 3
If I run npx tsx src/intex.ts | jg it works just fine.
src/index.ts can be as simple as:
console.log(`{"message": "Hello World!"}`)
Gotcha, thanks for the repro. Happy to accept a PR.
Same thing is happening when using
concurrentlyto run tsx watch, no console output at all.
Same thing for me, this is the only reason I cant switch from ts-node.