Running Typescript scripts in node using esbuild
node ./foo/script.js. I'll sometimes reach for
@babel/register, but that can be pretty difficult to configure sometimes, and has some perf issues.
It does work though, and I have a post on it...
However, I recently discovered that ESBuild has a similar mechanism to babel-node called
It's SUPER easy to use as well.
> npm i esbuild esbuild-runner
Then, anytime you run a
.ts file, you do...
node -r esbuild-runner/register ./path/to/script.ts
And it's stupid fast...
I hope to employ
esbuild-runner in some more local developer tooling so developers don't have to pre-compile or build their tools.