5 ms·
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 https://github.com/p
by rickcarlino 3y ago
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 https://github.com/privatenumber/tsx
- lloydatkinson 3y agoI 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.
- khalidx 3y agoI 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.
- privatenumber 3y agotsx v4 was released a couple weeks ago which addressed many incompatibility issues. Hope you have a chance to give it another shot :)
- khalidx 3y agoI definitely will!
- vmfunction 3y agoor esno, which is tsx with esbuild.
- lhnz 3y agoI'm using `esyes` [0] by Yehuda Katz and the logic is simple and it works very well. [0] https://github.com/starbeamjs/esyes https://github.com/starbeamjs/esyes
- vmfunction 3y agothanks for sharing! Didn't know about this one.
- madeofpalk 3y agotsx is "tsx with esbuild" though?
- domh 3y agoI 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!
- herpdyderp 3y agoTsx 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.
- privatenumber 3y agoMaintainer 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!
- e1g 3y agoCan confirm we use tsx with playwright with no issues. Thanks!
- herpdyderp 3y agoI see v4 was published just 12 days ago. I'll have to give it another shot! Thanks!
- bruh2 3y agoLove 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 https://github.com/esbuild-kit/esno
- madeofpalk 3y ago> From v0.15, esno is essentially an alias of tsx heh. It really is https://github.com/esbuild-kit/esno/blob/master/esno.js https://github.com/esbuild-kit/esno/blob/master/esno.js