3 ms·
As someone who regularly publishes npm packages [1], and have dealt with packages that do this, please don't. At least not yet until ESM is fully supported by
by paradite 4y ago
As someone who regularly publishes npm packages [1], and have dealt with packages that do this, please don't.
At least not yet until ESM is fully supported by all parties in the ecosystem (node, V8, major libraries and frameworks). As of Sept 2022, we still have support issues with node (V8), TypeScript and jest. I have links to the issues in one of my GitHub repos[2].
Once you move past trivial hello world apps, it is literally impossible to run JavaScript in node in pure ESM because of various bugs and incompatibilities. The user of the library will hit "Cannot use import statement outside a module" error sooner or later.
1: https://www.npmjs.com/~paradite https://www.npmjs.com/~paradite
2: https://github.com/paradite/github-dramas#2021 https://github.com/paradite/github-dramas#2021
- WorldMaker 4y agoNode 16+ and Typescript 4.7+ and recent versions of jest (I don't know offhand a version number) seem to have sorted most of the issues with using ESM modules at this point. I agree ESM was more trouble in 2021, but this deep in 2022 things are a lot rosier.