mridgway / hoist-non-react-statics

Copies non-react specific statics from a child component to a parent component
Other
1.8k stars 93 forks source link

Reduce bundle size #88

Open v1vendi opened 5 years ago

v1vendi commented 5 years ago

Hello! I saw that you race for minified size, and I have tried several options to minify the bunde for modern browsers for about 15%:

Unminified souce is also reduced by 400 bytes

Should I provide a PR for all of this or some points are useless?)

v1vendi commented 5 years ago

moving from const to let can also save some bytes, if you agree)

eps1lon commented 5 years ago

moving from const to let can also save some bytes, if you agree)

Did you measure the reductions after transpiling the code?

v1vendi commented 5 years ago

That's fun, for current rollup setup build size increases for all 3 of bundles (cjs, default and minified), as it builds to ES5. So the question now is should we optimize for older or for newer browsers. Decision is for you :)

v1vendi commented 5 years ago

Some more info - when I build the project as is, the minified file size is 6312b. When I add optimizations, file size grows to 6459b, but if I add a browserslist config with (for example) chrome > 49 I get 6181b.

Also this optimizations will be used by a large number of developers, who build hoist-non-react-statics with their own bundles So I'd still consider applying this micro-optimizations, even though they increase bundle size for old browsers and make some parts of code a bit more complex