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
Skip _extends
helper for {…x}
with modern targets
#12899
Conversation
@@ -0,0 +1,3 @@ | |||
let a = Object.assign({ | |||
x: 1 | |||
}, b); |
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.
Without this PR, the output would be something like
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
let a = _extends({
x: 1
}, b);
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/42582/ |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 81cbf0b:
|
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.
The future is on the horizon: preset-env
will be simplified to a static array of babel plugins.
Yes! 😄 |
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.
💯
The
_extends
helper already delegates toObject.assign
when it is available.If we statically know that
Object.assign
exists (using the user'stargets
), we can avoid injecting_extends
.