Hacker News new | ask | show | jobs
by moltar 850 days ago
Node has native top level await. However, figuring out how to make it work is an exercise in frustration for many.
3 comments

Yep! It requires ESM, which had other knock on effects in my codebase, IIRC with Lexical. I needed to hack around this a bit for Deno's module system as well (using esm.sh to preprocess Lexical) but it was a much nicer DX.
Is it much the same as trying to use esm in node while having legacy CJS code? Several options that end up with weird tradeoffs and bugs?
npm install -g tsx

Name your files .ts and run with tsx ./file.ts

All done, good to go

I just use npx vite-node or bun to run TS directly