I gave tsx a test and found it has a 3x slower boot than my favorite one, tsm[0] (and this is using the native binary at "./node_modules/bin/tsx").
Unfortunately, tsm has much lower download numbers compared to tsx, so I can already see me jumping ship to it due to traction.
I usually install tsm locally with "--save-dev" and use "node -r tsm --enable-source-maps <file>.ts" to run what I want. Here on a M1 Pro 32GB the difference between both is 0.17s for tsx and 0.06s for tsm.
I urge anyone that haven't tried yet to give tsm a chance. It works great with PM2 if you create a file like "server.pm2.js" and just add at the top of it "require('tsm')" followed by "require('server.ts')".
ts-node is responsible for my favourite error message in all of computing.
Yes better than: 'Error: success' or 'keyboard not found: press F1 to continue'
> ts-node: Unknown file extension: ts.
Someone will reply for a technical reason about this (mentioning .mts or package.json settings or whatever) but that doesn't change the fact that a program whose only job is to run ts files should know what a ts file is. GitHub issue: https://github.com/TypeStrong/ts-node/issues/1967
ts-node does not play well with ESM modules out of the box. I've started experimenting with tsx but it still has some edge cases of its own.
Honestly, ESM has been the bane of my existence this year as packages are slowly starting to migrate, and fixing issues lays on the developer, not any one framework.
rcarr|2 years ago
https://github.com/esbuild-kit/tsx
paiari|2 years ago
I gave tsx a test and found it has a 3x slower boot than my favorite one, tsm[0] (and this is using the native binary at "./node_modules/bin/tsx").
Unfortunately, tsm has much lower download numbers compared to tsx, so I can already see me jumping ship to it due to traction.
I usually install tsm locally with "--save-dev" and use "node -r tsm --enable-source-maps <file>.ts" to run what I want. Here on a M1 Pro 32GB the difference between both is 0.17s for tsx and 0.06s for tsm.
I urge anyone that haven't tried yet to give tsm a chance. It works great with PM2 if you create a file like "server.pm2.js" and just add at the top of it "require('tsm')" followed by "require('server.ts')".
[0] https://www.npmjs.com/package/tsm
jjice|2 years ago
nailer|2 years ago
Yes better than: 'Error: success' or 'keyboard not found: press F1 to continue'
> ts-node: Unknown file extension: ts.
Someone will reply for a technical reason about this (mentioning .mts or package.json settings or whatever) but that doesn't change the fact that a program whose only job is to run ts files should know what a ts file is. GitHub issue: https://github.com/TypeStrong/ts-node/issues/1967
tsx or @digitak/esrun both work out of the box.
johnfn|2 years ago
mattwad|2 years ago
Tade0|2 years ago
And introducing new extensions like .mjs or .cjs is the smoldering dead raccoon responsible for half of the smell.