Time for the periodic "how are ESM-only modules on npm doing" update:
Looked at some arbitrarily selected popular sindresorhus modules (delay, p-event), and >90% of installs continues to be of (now at least 4 years old) CommonJS versions.
Yeah, I don't think this qualifies as a success for ESM.
@joepie91 Something I've noticed is that because most packaging tools allow you to transparently use CJS within ESM and export ESM back to CJS, there's very little (to absolutely no) incentive for existing projects to rewrite all of their imports and deal with the more nuanced consequences of the change.
@crumbcake That holds true for (bundled) browser code; but crucially, not in environments with native support for modules, like Node.js, as there is no build step there.
Leading to a situation where everything seems to be 'fine' to people who only do browser-side code, but constant breakage in server environments of the same modules... 🥴
@crumbcake That matches what I've seen, though paired with a crucial other trend that makes this possible in the first place: a broader move towards monolithic frameworks that reinvent their own wheels.
It used to be that modules had a single well-specified purpose, and it did that well, and even frameworks were generally designed to be highly interoperable. This eliminated whole classes of issues like month-long framework upgrade chores, library architecture incompatibilities, and bugs in utility functions (because everyone used the same well-tested ones).
However, since Node.js ended up in the startup hype cycle, that has been changing, with increasingly many do-it-all frameworks appearing (because those are really easy to market - large feature lists!), that barely interact or interoperate with the ecosystem at all, instead having their own buggy homegrown implementations of existing tools inlined into their codebase.
That does mean those frameworks are unlikely to run into issues interoperating with the existing ecosystem of CommonJS modules and can therefore afford to do ESM, but for all the wrong reasons...