Skip to content

Instantly share code, notes, and snippets.

@GeoffreyBooth
Last active November 22, 2018 11:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GeoffreyBooth/1b0d7a06bae52d124ace313634cb2f4a to your computer and use it in GitHub Desktop.
Save GeoffreyBooth/1b0d7a06bae52d124ace313634cb2f4a to your computer and use it in GitHub Desktop.
Analysis of public NPM packages using the “module” field

I did some research into the package.json "module" field. I wrote some code to download all the the package.json files from all the public packages in the NPM registry. Here are some findings:

941 public NPM packages use the "module" field as of 2018-10-22.

Here are the top 30 packages, as ranked by number of public dependents (or see the full list):

Dependents Package Name "module" Field Value
16,286 should ./es6/should.js
15,472 sinon ./pkg/sinon-esm.js
1,641 redux es/redux.js
1,579 rollup dist/rollup.es.js
1,308 react-router es/index.js
1,154 ramda es/index.js
1,055 react-redux es/index.js
1,023 rollup-plugin-babel dist/rollup-plugin-babel.esm.js
845 vue dist/vue.runtime.esm.js
810 d3 index.js
649 node-fetch lib/index.mjs
637 rsvp dist/rsvp.es.js
567 redux-thunk es/index.js
560 history es/index.js
469 whatwg-fetch ./fetch.js
463 rxjs ./_esm5/index.js
410 react-bootstrap es/index.js
404 acorn dist/acorn.mjs
390 rollup-plugin-commonjs dist/rollup-plugin-commonjs.es.js
331 deepmerge dist/es.js
314 firebase dist/index.esm.js
248 material-ui ./index.es.js
239 pouchdb ./lib/index.es.js
236 graphql index.mjs
235 lolex ./lolex.js
234 precss index.js
210 angular-ui-router lib-esm/index.js
203 three build/three.module.js
181 bignumber.js bignumber.mjs
174 radium es/index.js

Some of these packages, like should and sinon and redux and vue and d3, surely have huge numbers of private dependents not reflected in the totals above.

Of the 941 packages that use "module", here are some numbers about file extensions:

  • 783 packages point directly to a .js file.
  • 75 packages point directly to an .mjs file.
  • 83 packages point to a filename with an implied (or no) extension, or a folder name.

Of the 858 packages that point directly to a .js or .mjs file, 274 point directly to files that use “multi-dot” file extensions:

  • 133 use .es.js
  • 84 use .esm.js
  • 13 use .es.mjs
  • 11 use .module.js
  • 10 use .es6.js
  • 7 use .m.js
  • 5 use .es5.js
  • 4 use .min.js
  • 2 use .next.js
  • 2 use .es2015.js
  • 1 each use .esm.js, .es8.js, .ems.js

Of the 83 packages that have "module" values that don’t end in .js or .mjs, most appear to point to files with an automatically-added extension (e.g. index):

  • 57 use index
  • 6 use es
  • 4 use dist
  • 2 use main
  • 1 each use components, Animate, DialogWrap, src, dist-es6, hashids-esm, module, vdt.esm, immupdate, immutable, esm, esmodule, Booth, please-wait, form-urlencoded

Collectively, the 941 packages using the "module" field have 41,226 public dependents (inclusive of duplicates, e.g. packages that depend on more than one "module"-using package).

Reading through the full list of public packages using "module", many appear to be related to the React, Vue and D3 ecosystems.

@SMotaal
Copy link

SMotaal commented Nov 8, 2018

This is very impressive work... vital for decisions ahead 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment