-
Notifications
You must be signed in to change notification settings - Fork 30
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
fix(components): Enabled Tree Shaking properly in Atlantis. #2117
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Deploying atlantis with Cloudflare Pages
|
Published Pre-release for 404bbfd with versions:
To install the new version(s) for Web run:
To install the new version(s) for Mobile run:
|
scotttjob
changed the title
fix(components): Enabled Tree Shaking properly in jobber components.
fix(components): Enabled Tree Shaking properly in Atlantis.
Nov 14, 2024
jdeichert
approved these changes
Nov 14, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested the pre-release in JO/JF, seems to be working as expected!
Updated and tested on JO and JF. Ready to go! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivations
We had a report that we weren't tree shaking properly, and users were getting reduced bundle sizes by using our legacy/compatibility bundles which was not intended (they are there to support legacy usages only).
This PR adds the required configuration to tell Rollup/Vite to properly tree shake our components.
We added
sideEffects: false
to our package.json. This tells bundlers that your code does not 'do' anything when loading the package. It has no side effects from loading the base entry point. Earlier this year we were forcibly injecting styles when loading our components, but we no longer do that (you have to import our styles manually via css) so this is now true!This PR also resulted in a few deep dives into Atlantis. We did two dives, one to see what it would look like to get a pure ESM build with no compatibility layers. The other was a dive to see what it would look like for us to replace rollup with vite in library mode.
In the wake of those dives, we have a list of tasks that can bring down our package size even further. The pure ESM build of Atlantis for instance is 60kb before tree shaking with room for further improvement via bundler configuration.
Screen Shots
These screenshots come from a 'clean' project that I created with Vite. I wanted the absolute bare minimum project to show the difference in sizes for built Atlantis with and without sideEffects on. Note gzip is not enabled, so sizes shown are uncompressed.
Legacy Imports
ESM Imports as of Today
This PR
Build for Prod with existing approach (in sample repo)
Build for Prod with this PR + Prerelease (in sample repo)
Changes can be
tested via Pre-release
In Atlantis we use Github's built in pull request reviews.