Refactor to use ES Modules + Rollup (CJS, ESM, UMD) + Babel + ESLint/Prettier
This is a big one: it includes a lot of changes and some stylistic ones so I'd understand if you don't like some of them and you might also not have the time to review it but I figured I tried. Also I have seen you were interested in switching to ES modules (https://github.com/bramstein/fontfaceobserver/issues/102) so here it is:
- Refactor to use ES Modules
- Use Rollup to get three bundles CJS, ESM, UMD
- Use Babel and encourage the use of babel-polyfill
- ESLint/Prettier for code consistency
- Remove Grunt in favour of Rollup
- Remove Closure Compiler in favour of Babel
- Use JSDoc to generate a documentation: https://dmnsgn.github.io/fontfaceobserver/
All tests are the same and passing in Node 4 to 8: https://travis-ci.org/dmnsgn/fontfaceobserver
You can see the output bundles keep a small size gzipped:
- https://unpkg.com/[email protected]/dist/fontfaceobserver.cjs.js (gzip 1.6 kB)
- https://unpkg.com/[email protected]/dist/fontfaceobserver.esm.js (gzip 4.26 kB)
- https://unpkg.com/[email protected]/dist/fontfaceobserver.umd.js (gzip 2.22 kB)
I published it on npm to have a play: https://www.npmjs.com/package/fontfaceobserver-es
Thanks
Nice freaking work, dude! Saving my life right now, since my project compiles with webpack and rollup. Of course it was freaking out about the commonjs export.
It would be wonderful if this was published as es modules.
Updated with latest commits and fixes: https://unpkg.com/[email protected]/dist/fontfaceobserver.esm.js
Fixed all the tests
Available to test from at: npm i fontfaceobserver-es
thanks!
Can I help anyway to make this PR merged? I think this is very important, Currently many projects use webpack or rollup, and having this library not being tree shakable is a big down for those.
In our case, we detected that our bundle size incremented > 40% due to just use this library, and we are investigating to move away from it for this very reason.
Thanks for the package fontfaceobserver-es .
Love to see this merged, please?
I can also confirm fontfaceobserver-es works when using the following import:
import FontFaceObserver from 'fontfaceobserver-es';