fontfaceobserver icon indicating copy to clipboard operation
fontfaceobserver copied to clipboard

Refactor to use ES Modules + Rollup (CJS, ESM, UMD) + Babel + ESLint/Prettier

Open dmnsgn opened this issue 7 years ago • 8 comments

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:

I published it on npm to have a play: https://www.npmjs.com/package/fontfaceobserver-es

Thanks

dmnsgn avatar May 25 '18 16:05 dmnsgn

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.

gmcdev avatar Nov 09 '18 02:11 gmcdev

It would be wonderful if this was published as es modules.

bennypowers avatar Nov 22 '18 14:11 bennypowers

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

dmnsgn avatar Mar 17 '19 11:03 dmnsgn

thanks!

scsskid avatar Aug 14 '19 10:08 scsskid

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.

sandinosaso avatar Jul 22 '20 16:07 sandinosaso

Thanks for the package fontfaceobserver-es .

tiye avatar Feb 05 '21 15:02 tiye

Love to see this merged, please?

danimalweb avatar Sep 14 '21 20:09 danimalweb

I can also confirm fontfaceobserver-es works when using the following import: import FontFaceObserver from 'fontfaceobserver-es';

rafagsiqueira avatar Aug 24 '22 13:08 rafagsiqueira