-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
babel-preset-default: enable the bugfixes option for preset-env #50994
Conversation
Size Change: -21.6 kB (-2%) Total Size: 1.39 MB
ℹ️ View Unchanged
|
In addition to untranspiled function parameters, we now also get untranspiled optional chaining with |
Perf tests are failing because the build is broken const getGroupPlaceholderIcons = ( name = 'group' ) => {
const icons = {
group: groupMarkup
};
return icons?.[ name ];
} is now minified into: ( name = 'group' ) => { group: groupMarkup }?.[ name ] which is nonsense because the opening We'll need to upgrade Terser. |
Locally, upgrading Terser fixed the broken code. In minified code, I see that the object and the optional chaining are no longer inlined together: (e='group')=>{
const t = {group:groupMarkup};
return t?.[e];
} Let's see if the CI checks get fixed, too. |
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.
Nice work @jsnajdr 🙌
Checks are green and everything looks good locally too. 🚀
Babel has a
transform-parameters
transform plugin that transpiles all kinds of function parameters: destructuring, spread operators, ...Today all supported browsers have full ES6 support, so this transform shouldn't be active. But it is. Because Safari has an obscure bug in one destructuring edge case (https://bugs.webkit.org/show_bug.cgi?id=220517), it's not 100% safe to leave destructuring code untranspiled. That's why
transform-parameters
is active by default and we get all ES6 function parameters syntax transpiled.See this screenshot where an innocent
[ key, attribute ]
destructuring gets transpiled:That's why Babel has a
bugfixes
option. It replaces thetransform-parameters
plugin with a more targeted one that transpiles just that one Safari edge case.Enabling this option removed all that unnecessary transpilation:
It is planned to be enabled by default in Babel 8, so it should be safe for Gutenberg, too.
Related to #50987.