-
-
Notifications
You must be signed in to change notification settings - Fork 163
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
Very slow (4x slower than ts-node
)
#167
Comments
Thanks for the report. I'm happy to investigate but your reproduction isn't minimal at all. Do you mind removing all irrelevant code? I'm guessing the bottleneck is caused by |
Minimal reproduction: https://github.com/brillout/tsx-slow-minimal. It really seems like |
This comment was marked as off-topic.
This comment was marked as off-topic.
I feel like a lot of this processing is no longer necessary, considering all maintained LTS versions of Node have supported ESM natively for a while. Could we experiment with dropping all processing of CJS modules and |
tsx aims to support older versions of Node.js down to the latest v12, but I agree we can definitely make improvements on this. I haven't had the time but I plan on testing esbuild's transformations to see which ones are necessary for which Node.js versions so I can start applying them more selectively. |
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This was actually not super slow for me to begin with, but it was 2.5x slower compared to ts-node. In https://github.com/privatenumber/tsx/releases/tag/v4.0.0, we optimized compilation to be more selective by implementing ESM detection. Hope this works well for you! Benchmarks using Node.js v18.7.0Before (tsx v3)tsx was slower
After (tsx v4)tsx is now slightly faster
Compared to Node.jsStill a long way to go to get similar speeds to Node.js. Will rinvestigate this benchmark further.
|
Bug description
Given that tsx uses esbuild I'd expect to be fast, really fast.
But, in my case, it's slow, prohibitively so.
I'm guessing that's because tsx doesn't externalize
node_modules/
. Am I correct with that assumption? In my experience esbuild is pretty much instantaneous most of the time. Yet, for a server that has only 50 LoC (see real-world reproduction),tsx
takes more 12 seconds, whereasts-node
takes 3 seconds.I love many things about tsx (especially its wonderful work on ESM-CJS compat) but its slowness is a blocker.
Strictly speaking, this isn't a bug, but I do consider it as a flaw big enough to justify the existence of this GitHub issue.
Thanks a lot for tsx, I just wish tsx would externalize
node_modules/
.Reproduction
Real-world reproduction: https://github.com/brillout/tsx-slow.
Minimal reproduction: https://github.com/brillout/tsx-slow-minimal.
Environment
Can you contribute a fix?
The text was updated successfully, but these errors were encountered: