3 ms·
Remember we’re using Node. I don’t think TypeScript compiler supports importing ESM into CommonJS files. Basically we will have to move the library to ESM and
by ushakov 3y ago
Remember we’re using Node. I don’t think TypeScript compiler supports importing ESM into CommonJS files.
Basically we will have to move the library to ESM and then use a bundler like esbuild to compile it to CJS as well for compatibility. It’s a mess
- josteink 3y ago> It’s a mess I think everyone agrees about this. What people can’t agree about is how to fix it.
- vinnymac 3y agoI haven’t really struggled too much here. Maybe an aversion to bundlers exists, but I think tsup and vite are great and simple. We have turbopack on the horizon too. For small projects I don’t even need a configuration file for tsup to target both formats. For larger more complex projects vite configs tend to be under 50 LoC.
- herpdyderp 3y agoTry using the tsx package for running Node in situations like this. It magically “just works” https://www.npmjs.com/package/tsx https://www.npmjs.com/package/tsx