Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance Issue: Doesn't support tree shaking #959

Closed
cseas opened this issue Jan 17, 2023 · 4 comments · Fixed by #1045
Closed

Performance Issue: Doesn't support tree shaking #959

cseas opened this issue Jan 17, 2023 · 4 comments · Fixed by #1045
Labels
enhancement New feature or request 🤔 Needs discussion This needs some internal discussions

Comments

@cseas
Copy link
Member

cseas commented Jan 17, 2023

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

  • Use preserveModules option from Rollup to retain original tree in the bundled package.
  • Add sideEffects field to package.json to signal to bundlers to use tree shaking.
  • Fix the output format of the bundle. While it does have import/export statements, I see it's also full of var declarations so we need to update the output format (maybe generatedCode: "es2015").

Screenshot 2023-01-17 at 10 18 49 AM

@cseas cseas added the enhancement New feature or request label Jan 17, 2023
@saurabhdaware
Copy link
Member

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

@anuraghazra
Copy link
Member

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

@adilk121
Copy link

yes correct

@saurabhdaware
Copy link
Member

#1045

This PR will fix the tree shaking 👯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request 🤔 Needs discussion This needs some internal discussions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants