question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use ES6 modules + Rollup

See original GitHub issue

As 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.

cc @tmcw @Yomguithereal

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
tmcwcommented, Apr 15, 2017

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.

0reactions
DenisCarrierecommented, Sep 23, 2017

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ES6 modules · rollup/rollup Wiki - GitHub
For Rollup to work its magic, it needs the library to be written in ES6 modules. The library's package.json file should use the...
Read more >
rollup.js
Rollup is a module bundler for JavaScript which compiles small pieces of code into something larger and more complex, such as a library...
Read more >
How to Bundle JavaScript With Rollup — Step-by-Step Tutorial
Rollup is a next-generation JavaScript module bundler. Author your app or library using ES2015 modules, then efficiently bundle them up into a single...
Read more >
How to Build and Publish ES6 Modules Today, with Babel and ...
Now you can build your library by running “node tools/build” (assuming you have Node.js 6 installed on your local machine) and publish it...
Read more >
Using rollup.js with es6 - javascript - Stack Overflow
This is a follow-up question to How to set up rollup.js with a d3 plugin?. I have little dummy module foo.js: //.src/foo.js import...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found