Draft-js: ESM support

Created on 4 Sep 2018  路  4Comments  路  Source: facebook/draft-js

Draft-js is a great project however for my team it's a huge bundle bloat.
image

I would like to suggest to migrate the whole code base to esm and then distribute esm. This with some more tweaks should reduce library size significantly.

I could start working on this but haste module system may be a blocker on facebook side so I need your opinion on this guys.

enhancement

All 4 comments

@TrySound - I suspect that this will cause issues but I'm not very familiar with ESM. Tagging some folks who may know more - @claudiopro, @elboman, @mrkev

@TrySound what tweaks are you thinking about? Tree shaking?

I'm not sure that ESM alone would do a whole lot about changing the size of the library: what could bring benefits is making it modular (kind of like codemirror) and allowing people to import only the features they need.

Here's a few results after string-replace converting to esm. All results is webpack output in production mode

initial build of lib/Draft.js

320125 B

bundle all draft files with rollup

312493 B

deduplicate babel helpers

301462 B

And this result can be even better after more improvements

Hmmm, I checked in with the React folks to learn about their release-- it's a bit more complicated and changes perhaps we could do something similar. I'll bring it up for discussion with the rest of the team on the next meeting.

Thanks for this investigation! If you could push a repo with these changes so I can play around with them too that'd be much appreciated 馃憤

Was this page helpful?
0 / 5 - 0 ratings