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 (3)
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.