5 ms·
Tsconfig-to-dual-package – Node.js tool to support CJS and ESM in one package
- rektide 4y agoTheres millions of typescript packages authored in esm, but which output/target CJS. Many old & not actively maintained but still very useful. It was only TypeScript 4.8 released last made NodeNext target available, that made esm+node reslly possible & good..I hate to say it, but this is a huge huge huge problem TypeScript has infected the npm package world with, and we will be reckoning with this for a long time. Interesting tool! Not sure it's worth actually supporting CJS at anymore. Node 14 leaves maintenance in April, then Node 16 has an extra short release that ends October, and Node 18 has quite good ESM support. Folks really should be moving forward to the language's official module support in haste at this point. For some, & library maintainers, doing dual releases is a fine interim step. Albeit many library maintainers have just stopped doing CJS; very worth considering for your own libraries too. If someone has CJS needs, it more & more is on them to figure out their own transpilation down & their own compatibility tooling.
- wdb 4y agoStill unclear to me what the benefits are for ESM. So far it is a pain in the ass because a few developers force ESM through your throat.
- rektide 4y agoImports can be statically parsed, such that a runtime can figure out what to load before executing. This makes it a viable standard for all runtimes, unlike CJS. Also, it's a the official standard for the language & anyone doing anything else is just off in their own corner not doing the language.