You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We currently provide CommonJS and ESM entry points.
While ESM is able to import CommonJS packages, the opposite does only work with dynamic import() and not with require().
This causes issues as some of our dependencies are pure ESM dependencies, meaning our CJS output is theoretically invalid, because it contains require('pure-esm-module').
This causes issues with tools like jest, as the code is not valid.
(Notice that for app users this is not a problem, if they use Vite it will load the ESM entry and if they use webpack it will transpile this library and all dependencies to UMD)
But I see no benefit of providing both types, as CommonJS users will still have to transpile this library because of the dependencies.
My reasons for going pure ESM:
Less error prone distribution (we had problems with one of both types being invalid with both webpack and vite)
ESM is the standard (and hopefully someday being it also in the Node.js universe)
Simplify tooling & build process
Smaller distribution size
Needs to be transpiled anyway so should be no change for users.
I am happy to hear your thoughts, especially if you know reasons for keeping both 😃
The text was updated successfully, but these errors were encountered:
We currently provide CommonJS and ESM entry points.
While ESM is able to import CommonJS packages, the opposite does only work with dynamic
import()
and not withrequire()
.This causes issues as some of our dependencies are pure ESM dependencies, meaning our CJS output is theoretically invalid, because it contains
require('pure-esm-module')
.This causes issues with tools like jest, as the code is not valid.
(Notice that for app users this is not a problem, if they use Vite it will load the ESM entry and if they use webpack it will transpile this library and all dependencies to UMD)
But I see no benefit of providing both types, as CommonJS users will still have to transpile this library because of the dependencies.
My reasons for going pure ESM:
I am happy to hear your thoughts, especially if you know reasons for keeping both 😃
The text was updated successfully, but these errors were encountered: