4 ms·
And ship a commonjs version as well, if you need to support older node versions. It's trivial.
by fckthisguy 4y ago
And ship a commonjs version as well, if you need to support older node versions. It's trivial.
- oefrha 4y agoIt’s actually pretty annoying that some people are now going pure esm and actively removing cjs builds. There are certain libraries that don’t work with esm yet, so if you need one of those suddenly all the esm-only packages can’t be used.
- laundermaf 4y ago> certain libraries that don’t work with esm yet I assume that you're talking about tools rather than libraries. Any simple library can import ESM asynchronously and any ESM packages can import CJS packages even with static imports. Tools and Node’s strict ERR_REQUIRE_ESM have been the problem with the migration.
- conaclos 4y agoIn my experience, you may encounter issues when you depends on pure esm package and cjs-only packages. IMHO, it is still useful to publish a cjs fallback.
- laundermaf 4y agoYou may encounter issues with mixed packages too, actually a lot more issues given that people expect `module.exports = ` and `export default` to be equal but are not. Just save yourself some headache and publish either ESM or CJS, not both.