Skip to content

chore: Improve bundle size #5761

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

Merged
merged 6 commits into from
Jan 18, 2023
Merged

chore: Improve bundle size #5761

merged 6 commits into from
Jan 18, 2023

Conversation

BrunoQuaresma
Copy link
Collaborator

TLDR: The main bundle index.js was reduced from 499.45 KiB to 355.74 KiB and reduced the size of the pages were using the emoji picker.

I noticed Vite was showing a warning about one of the chunks getting larger than 500 KiB so I installed a plugin to start the analyses and to make it easier in the future, I added an npm script: yarn stats.

The initial analyses:
Screen Shot 2023-01-17 at 19 15 29
Screen Shot 2023-01-17 at 19 39 23

  • I noticed the emoji plugin was adding a lot of stuff in the main chunk
  • I also noticed lodash was doing the same even though we don't use it too much

What I made:

  • We already had a plugin called IconField that was abstracting the emoji usage but we were not using it consistently, so I refactor the code to use it. After that, I created a lazy version of this component, so it could be loaded when it is needed only.
  • I noticed the testHelpers was importing the range function directly from the lodash bundle instead of specifying the full path.

Result:
Screen Shot 2023-01-17 at 19 37 35
Screen Shot 2023-01-17 at 19 37 51

@BrunoQuaresma BrunoQuaresma requested a review from a team as a code owner January 17, 2023 22:46
@BrunoQuaresma BrunoQuaresma requested review from code-asher and removed request for a team January 17, 2023 22:46
@BrunoQuaresma BrunoQuaresma self-assigned this Jan 18, 2023
@BrunoQuaresma BrunoQuaresma enabled auto-merge (squash) January 18, 2023 17:25
@BrunoQuaresma BrunoQuaresma merged commit 2117eb4 into main Jan 18, 2023
@BrunoQuaresma BrunoQuaresma deleted the bq/visualizer branch January 18, 2023 17:31
@github-actions github-actions bot locked and limited conversation to collaborators Jan 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants