-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Import from individual react-dates component #21914
Merged
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
This avoids the tree-shaking issues in `react-dates` that end up causing too much of the library to be imported when importing from the index.
sgomes
added
[Type] Performance
Related to performance efforts
[Package] Components
/packages/components
labels
Apr 27, 2020
sgomes
requested review from
ajitbohra,
chrisvanpatten,
jorgefilipecosta and
youknowriad
as code owners
April 27, 2020 09:56
I'm loving these PRs @sgomes :) Thanks for your help with the bundle size. |
Size Change: -18.5 kB (2%) Total Size: 816 kB
ℹ️ View Unchanged
|
youknowriad
approved these changes
Apr 27, 2020
Thank you for the review, @youknowriad! 👍 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
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.
Description
There is only one
react-dates
component in use in Gutenberg, which is currently being imported with a named import:This PR changes that to importing the internal library component directly:
This is more fragile with regards to library updates, since it uses knowledge of package internals, but it avoids the tree-shaking issues in
react-dates
that end up causing too much of the library to be imported when importing from the index.This should save around 96KB on the components chunk, or 19KB over the wire, although the GitHub action will have the final say.
I believe the trade-off is worth it, since it basically only involves some extra vigilance when updating
react-date
versions.Partially works towards resolving #21820.
How has this been tested?
Ran unit tests, performed build, and performed some ad-hoc testing of date picker functionality.
Types of changes
This is essentially a bug fix, in that it works around what I'd consider a bug in
react-dates
: that it doesn't tree-shake correctly.Checklist: