Skip to content

Data on the share of ESM vs CJS on the public npm registry

License

Notifications You must be signed in to change notification settings

wooorm/npm-esm-vs-cjs

Repository files navigation

npm-esm-vs-cjs

Build

Data on the share of ESM vs CJS on the public npm registry.

Contents

What is this?

This repository contains (historical) data on high-impact (popular) packages and what kind of code they expose:

  • ESM — such as type: 'module' in package.json
  • dual — such as both import and require conditions in export map
  • faux ESM — module field in package.json, supported by some old bundlers
  • CJS — anything else (except for @types/*)

When should I use this?

Use this data for rough insights on how the shift to ESM is progressing. The data isn’t perfect though.

Data

index.svg:

index.csv:

date,total,esm,dual,faux,cjs
2021-08-24,5617,341,95,832,4349
2021-11-09,5647,411,119,809,4308
2022-01-27,5686,439,149,809,4289
2022-08-01,5734,496,207,791,4240
2022-11-04,5747,518,216,785,4228
2023-02-06,6085,568,255,856,4406
2023-05-29,6240,630,417,783,4410
2023-08-24,6636,676,473,876,4611
2023-11-22,6818,734,510,881,4693
2024-02-20,7042,826,594,893,4729
2024-05-27,7042,819,736,826,4661
2024-08-28,7638,923,876,876,4963
2024-11-27,8087,942,1152,843,5150

👉 Note: the crawl of 2024-05-27 adjusts several packages that were previously classified incorrectly as dual.

👉 Note: crawls from before 2022-11-04 use the list of popular packages on the date of 2022-11-04, as I had the results of all packages, but not which of them were popular back then. Later dates will use a list of what’s popular on that date.

👉 Note: not all of these packages are popular. There are some false-positives, such that download counts can be gamed, and that libraries.io sometimes thinks that a fork of webpack or so is actually webpack.

👉 Note: while @types/* packages are filtered out in the above counts, it is likely that there are other packages included that aren’t really code, particularly in the CJS category (as that’s the default).

Scripts

This repo includes scripts to crawl npm and analyze the results. You need a NPM_TOKEN environment variable with a token to crawl npm.

script/crawl.js analyzes the package.json files of latest releases of high-impact npm packages. This script finishes in about 5 minutes. You should likely first contribute to npm-high-impact, which can take like 24 hours to complete.

script/analyze.js analyzes the data files and generates SVG and CSV files from them. After running that, please copy/paste the new .csv into this readme above.

Contribute

Yes please! See How to Contribute to Open Source.

Security

This package is safe.

License

MIT © Titus Wormer

About

Data on the share of ESM vs CJS on the public npm registry

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project