If you use typescript, nodemon and ts-node for development.
You'll notice that it takes a while to recompile the code when it changes.
tsx is a Typescript execute which blazing fast ⚡️ with esbuild.
Installation
I prefer use pnpm but you can use npm, yarn, ...etc.
pnpm add -D tsx
Now you can uninstall nodemon and ts-node.
pnpm remove nodemon ts-node
Add script tsx watch [file/folder]
in the package.json.
{
"name": "use-tsx",
"version": "1.0.0",
"main": "index.ts",
"scripts": {
"dev": "tsx watch src",
},
"devDependencies": {
"@types/node": "^18.7.18",
"tsx": "^3.9.0",
"typescript": "^4.8.3",
}
}
Let's start.
pnpm dev
refs:
Top comments (7)
I would recommend swc with ts-node. Its super-fast.
Yes in some cases, but tsx is the most compatible.
So you can see in ts-runtime-comparison
When you look at the size comparison plus bugs, you can easily know which one is preferable.
10 bug issues is a negligible number and install size difference of few Mbs does not matter on BE at all. TSX is the most reliable & feature-rich. Superior to those alternatives.
It's not a few MBs difference. It is 1 MB v/s 10 MB. Bundle size matters in speed/performance.
TSX being built under esbuild makes it faster and more feature-rich. You can argue on the library's size but it's a dev dependency and the bundle size of your application is considerably smaller than the other ones. Your 1 mb library will give you a bad dev experience and compile a 30mb bundle. The 10mb library will have the most cutting edge features and will compile a 10mb bundle.
Thanks man, i was getting crazy over this tsx, nodemon, ts-node, pnpm, npm
it's crazy, so many years, so. many thing incompatible