Over the past 14 months, I was curious in how many of some of the top npm packages are switching over to ES Modules now that all LTS versions of Node support ES Modules as well as every single modern browser supported it. I created a service called esm-checker. With it, unluckily there really wasn't a great amount of movement. Between Jan 1, 2022 and as of today, you can see the following results.
- Exports Require: 69
- Exports No Require: 275
- Type Module: 204
- Exports Require: 127
- Exports No Require: 310
- Type Module: 238
For reference again here is the legend used for the three data points.
- type_module: A module that explicitly set the type for the package to "module" which will treat all .js files as ESM by default.
- exports_require: A module that has an "exports" field that explicitly has a "require" field which allows a module to be required with a CJS fallback.
- exports_no_require: A module that has an "exports" field that does not have a "require" field, so it may not have a CJS fallback.
The core thing is a large number of packages that have bumped up
exports_no_require are one individual, Sindresorhus, who is going ESM-only and not supporting dual packages. He wrote the following gist back in February 2021: Pure ESM Package but it came upon some major scrutiny that he was taking a hard stance of only supporting ESM and nothing else, to the point that he now has deleted a good amount of the contents of comments on the gist and wrote last February that the thread was considered lock and any comments (whehter for or against ES Modules) would be deleted. As well, other well-known packages have gotten similar scrutiny for going ESM only: ESM only breaks everything - node-fetch.
As a final result for this expiriment, I've lead to believe that the majority of the existing ecosystem of JS is unlikely to migrate over. Libraries like Typescript and Nextjs do support ESM now, but the vast majority is not moving over. For personal projects I'm sticking with CommonJS as there aren't really any downsides and if I need to compile / bundle code down to run on the browser, tools like Webpack or Rollup still work for such.
As well, with this, I'll be spinning down the esm-checker site. As of today, the daily updates have stopped and the site will stay dormant from here on out. If anyone wants to continue it on, the code for the data collection and website are both on GitHub.