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

Perf: Better Tree Shaking #16

Merged
merged 3 commits into from
Feb 26, 2021
Merged

Perf: Better Tree Shaking #16

merged 3 commits into from
Feb 26, 2021

Conversation

tylerkrupicka
Copy link
Contributor

@tylerkrupicka tylerkrupicka commented Feb 25, 2021

What Changed

I noticed the size of some of the components was pretty large, and did some digging to find out why. It turns out our package template is missing the sideEffects tag, so dependencies were never being tree-shaken.

This meant that:

  • @design-systems/theme was never tree shaking based on usage.
  • AutoThemeProvider was pulling in all of ua-parser-js and all themes.

Breaking that apart and adding sideEffects dropped the size of the components, but there are still a couple issues remaining.

image

Webpack is pulling in a buffer polyfill that is huge, probably because the Object value and parser reference the type Buffer. I think this might just be something to change in the size command webpack config but I need to check.

The last optimization would be to just directly pull in the regex we need to detect firefox, so we don't need a full UA parser.

@tylerkrupicka tylerkrupicka added the patch Patch version change label Feb 25, 2021
@tylerkrupicka
Copy link
Contributor Author

tylerkrupicka commented Feb 25, 2021

Bundle Size Report

name master pr +/- %
@devtools-ds/object-parser 2.47 kB 2.47 kB 0.00 Bytes 0%
@devtools-ds/port-controller 11.03 kB 11.03 kB 0.00 Bytes 0%
@devtools-ds/themes 30.69 kB 6.01 kB -24.68 kB -80%
@devtools-ds/object-inspector 71.96 kB 21.25 kB -50.72 kB -70%
Total 116.15 kB 40.76 kB -75.39 kB -65%

✅ No size breaking changes detected

Courtesy of your bundle-size bot 📦🚀

@tylerkrupicka
Copy link
Contributor Author

Build Info

Your PR was successfully deployed by CircleCI #333

Storybook

@tylerkrupicka tylerkrupicka merged commit edbeaf4 into master Feb 26, 2021
@tylerkrupicka
Copy link
Contributor Author

🚀 PR was released in v1.0.3 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch Patch version change released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant