Use ES6 modules + Rollup
See original GitHub issueAs the front-end world rapidly moves to ES6-compatible bundling, simple-statistics could really benefit from switching from CommonJS to ES6 modules and Rollup. It may introduce small additional set up for tests and NPM prepublish scripts, but advantages now overweight the cons IMO. The library will especially benefit from tree-shaking (also see #180), leaner browser builds, and being future-proof.
SS would still have a CommonJS-compatible entry point for Node, but additionally use pkg.module
for ES6-aware consumers. The Webpack code splitting issues should not hold us back because they’re not ES6-specific, and are probably still a problem when you try to set up code splitting with CommonJS modules.
Examples of other libraries that switched happily to Rollup include React, Vue, Ember, Preact, D3, Three.js, Moment and PouchDB.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (6 by maintainers)
Top GitHub Comments
My opinion here: yep, let’s do it. The time has come for ES6 modules, and this’ll also let us switch out of Flow comment syntax ( https://github.com/documentationjs/documentation/issues/729 ) and use prettier.
Implemented ES6 modules using only Rollup,
@std/esm
wasn’t necessary (Rollup bundles are so fast, 1.5s for entire bundling process including uglifying).Using
@std/esm
actually compiles to the code and stores it in.esm-cache
, so it’s not any difference then Rollup, still takes time to compile every it’s executed.@std/esm
doesn’t seem viable for publishing official libraries, it’s better to set up a good Rollup configuration.