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
Prevent duplicate Babel object spread helpers. #35136
Conversation
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: App Entrypoints (~185 bytes added 📈 [gzipped])
Common code that is always downloaded and parsed every time the app is loaded, no matter which route is used. Sections (~2202 bytes removed 📉 [gzipped])
Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to. Async-loaded Components (~812 bytes removed 📉 [gzipped])
React components that are loaded lazily, when a certain part of UI is displayed for the first time. Legend What is parsed and gzip size?Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory. Generated by performance advisor bot at iscalypsofastyet.com. |
The fix is working correctly and spread helper duplication is no longer an issue after this PR. However, this doesn't appear to have produced noticeable size savings, according to the bot. Edit: The bot appears to be wrong. See below. |
The numbers that icfy is reporting don't make sense to me. If we follow the graph for According to the graph, it goes up from ~184000 to ~188000. From there, it stays at ~188000 until now. When looking at the branch view for this PR, the That would mean that it would still be at ~188000. However, downloading the relevant file from the live branch and gzipping it (at maximum compression, to match the supposed compression level default in In fact, I downloaded all relevant live branch versions and compared their gzipped sizes, making sure the gzip compression takes place in my machine, with the same settings for all of them, to ensure consistency. First, here are the links (you may have to rebuild the live branches): Before Babel upgrade. Refers to commit 368279e. And here are the sizes after
As such, we're in a much better place after this PR than after the Babel upgrade (and even a bit better than before!), but icfy doesn't seem to reflect that. CC @jsnajdr, as the main caretaker for icfy. Edit: added the parent commit to the comparison, for good measure. Edit 2: The branches above no longer reflect the current status of this PR, which has since been rebased, but the point they make still stands. |
Reviewers: to summarise, this PR is ready for review and does produce the expected bundle size improvements. See above for a deep dive into why that's the case despite what ICFY reports. |
Is there an upstream issue or something else we can link to from the code comment (to remind us at which point we'll be able to remove that line)? |
There is, sorry I forgot to include it! See babel/babel#10261 |
Could you add a note to |
Sure thing, done! |
With version 7.5.x of Babel, the object spread helper was updated to fix some issues. When we upgraded Babel to 7.5.5, it started trying to use the new helper to perform object spreads. This would have been fine, since the relevant package (transform-runtime) was part of the upgrade, but Babel sadly assumes that its version is older, instead of auto-detecting. This change explicitly indicates which version of the transform-runtime we're using, fixing the issue. It unfortunately adds extra maintenance overhead to Babel upgrades, but the Babel authors are considering adding the aforemention auto-detection, at which point we could remove the explicit definition. See babel/babel#10261
c9428ac
to
07bee75
Compare
Rebased on master. |
07bee75
to
2122f5d
Compare
Friendly ping for a review. Free performance gains right here! 😄 |
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.
Looks good, thanks for debugging this!
Thanks for the review, @jsnajdr ! 🙇 |
Confirmed a ~3KB difference in @jsnajdr The ICFY graph for |
Yep, putting that on my TODO list 🙂 |
* Prevent duplicate Babel object spread helpers. With version 7.5.x of Babel, the object spread helper was updated to fix some issues. When we upgraded Babel to 7.5.5, it started trying to use the new helper to perform object spreads. This would have been fine, since the relevant package (transform-runtime) was part of the upgrade, but Babel sadly assumes that its version is older, instead of auto-detecting. This change explicitly indicates which version of the transform-runtime we're using, fixing the issue. It unfortunately adds extra maintenance overhead to Babel upgrades, but the Babel authors are considering adding the aforemention auto-detection, at which point we could remove the explicit definition. See babel/babel#10261 * Add note to changelog. * Add issue comment to Babel config too.
* Prevent duplicate Babel object spread helpers. With version 7.5.x of Babel, the object spread helper was updated to fix some issues. When we upgraded Babel to 7.5.5, it started trying to use the new helper to perform object spreads. This would have been fine, since the relevant package (transform-runtime) was part of the upgrade, but Babel sadly assumes that its version is older, instead of auto-detecting. This change explicitly indicates which version of the transform-runtime we're using, fixing the issue. It unfortunately adds extra maintenance overhead to Babel upgrades, but the Babel authors are considering adding the aforemention auto-detection, at which point we could remove the explicit definition. See babel/babel#10261 * Add note to changelog. * Add issue comment to Babel config too.
FYI: specifying a version of the runtime that the plugin is not aware of breaks it. It should probably just use all the features when it sees a version beyond its current one (maybe aside from a breaking version bump) |
Somewhere on the range of version 7.5 of Babel, the object spread helper was updated (to fix some edge cases, I believe).
When we upgraded our version of Babel to 7.5.5, it started trying to use the new helper to perform object spreads. This would have been fine, since the relevant package (
transform-runtime
) was part of the upgrade, but Babel sadly assumes that its version is older, instead of auto-detecting.This change explicitly indicates which version of the
transform-runtime
we're using, fixing the issue. It unfortunately adds extra maintenance overhead to Babel upgrades, but the Babel authors are considering adding the aforementioned auto-detection, at which point we could remove the explicit definition.CC @jsnajdr, who'd been looking at the bundle size increase with me.
Changes proposed in this Pull Request
transform-runtime
we're using, to prevent helper duplication.Testing instructions
There should be no special testing needed other than opening the live branch and ensuring nothing breaks after visiting a page or two. Babel transformations are so low level that a mistake would likely break everything.
To confirm the bundle size improvements,
the icfy bot should be enoughsee my comments below.