razorpay / blade

Design System that powers Razorpay
https://blade.razorpay.com
MIT License
483 stars 124 forks source link

Performance Issue: Doesn't support tree shaking #959

Closed cseas closed 1 year ago

cseas commented 1 year ago

Problem

Blade ships all components into one flat file (@razorpay/blade/build/components/index.web.js) which bundlers in consumer projects cannot tree shake. To support tree shaking, Blade needs to ship with the original tree structure of the project.

For example, if a user imports one component from Blade (say Button), they will get all the components & utils from Blade in their final build. This hurts performance of the applications built with Blade since the bundles delivered to the browsers/apps are much bigger than they need to be.

See example main.bundle.js built with Blade by using one Button.

Suggestion

Screenshot 2023-01-17 at 10 18 49 AM

saurabhdaware commented 1 year ago

I think Anurag recently checked this and it was working. @anuraghazra can you confirm?

anuraghazra commented 1 year ago

@cseas thanks for the concise testing & the repro, i'll get back to you after testing it on my end.

adilk121 commented 1 year ago

yes correct

saurabhdaware commented 1 year ago

https://github.com/razorpay/blade/pull/1045

This PR will fix the tree shaking 👯