Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I’ve found TSX to be a better alternative to ts-node. It seems to have more sensible defaults in 2023. https://github.com/privatenumber/tsx


Love this project, used it quite a bit. However I always opt for using esno[1] instead, merely because of the name; having two tools share the same name throws me off.

[1] https://github.com/esbuild-kit/esno


> From v0.15, esno is essentially an alias of tsx

heh. It really is https://github.com/esbuild-kit/esno/blob/master/esno.js


I was about to say exactly this. If you’re writing Node scripts there’s no reason to use ts-node as tsx, by default, does the correct thing and works correctly with ES modules.

Of course, Deno offers a better experience for scripts or programs.


I tried `tsx` but it didn't work for some reason (can't remember why right now). Also, if you've been using `ts-node` and feel comfortable with it, this setup should work for you instead of switching your toolchain.


tsx v4 was released a couple weeks ago which addressed many incompatibility issues. Hope you have a chance to give it another shot :)


I definitely will!


Tsx is great but doesn’t work in all situations unfortunately. Some broken cases that I remember off the top of my head are Playwright and test coverage.


Maintainer of tsx here.

tsx should be able to handle Playwright as of v4+, and hopefully the test coverage you're referring to.

Before, it was compiling ESM syntax to CJS as an effort to ease the ecosystem's CJS -> ESM migration, and hiccuping whenever it encountered `eval()`. Now it includes smarter checks to determine if a file needs to be compiled at all and skips processing most dependencies.

Hope it works well for you!


I see v4 was published just 12 days ago. I'll have to give it another shot! Thanks!


Can confirm we use tsx with playwright with no issues. Thanks!


I use node-dev which seems to have good ts support. node-dev with --respawn is a good cheap way to watch and rerun ts files on change!


or esno, which is tsx with esbuild.


I'm using `esyes` [0] by Yehuda Katz and the logic is simple and it works very well.

[0] https://github.com/starbeamjs/esyes


thanks for sharing! Didn't know about this one.


tsx is "tsx with esbuild" though?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: