In this release: multiple improvements to the react-constant-elements
plugin by @STRML, some codegen optimizations, and lots of bug fixes! Thanks to @loganfsmyth for the release + reviews!
Shoutouts to @xtina-starr, @finkef, @chitchu, @yongxu, @jwbay, @hex13 for their first PRs! 🎉
Check out GitHub for the whole changelog.
I'll be writing up the 7.0 post (our current progress) soon so look out for that! We want to do whatever we can to make it easy for both end-users and plugin/tool authors to upgrade seamlessly: whether it be a beta period for the release, a 7.0 upgrade guide, codemods if necessary, a bot to automatically upgrade your OSS project from 6 to 7, or any other suggestions you can give us!
Since not everyone realises, I wanted to re-iterate again that our team is still a small group of volunteers. There's no company sponsor or even anyone working on it full time.
We'd love for you to contribute (especially not code!), so please reach out to us! More designers, technical writers/editors, and teachers for our website would be amazing.
And in other news, Babel has been accepted as a Rails Girls Summer of Code project as well as waiting to hear back as a mentor organization for Google Summer of Code!
🚀 New Feature
#5236 transform-es2015-block-scoping
: Add option throwIfClosureRequired
to throw on slow code. (@spicyj)
{
"plugins": [
["transform-es2015-block-scoping", {
"throwIfClosureRequired": true
}]
]
}
In cases such as the following, it is impossible to rewrite let/const without adding an additional function and closure while transforming:
for (let i = 0; i < 5; i++) {
setTimeout(() => console.log(i), 1);
}
In extremely performance-sensitive code, this can be undesirable. If "throwIfClosureRequired": true
is set, Babel throws when transforming these patterns instead of automatically adding an additional function.
#4812 transform-react-constant-elements
: Support pure expressions (@STRML)
Adds a path.isPure()
check to the plugin.
The expression will remain in the hoisted code, even though it could be statically evaluated. UglifyJS/Babili will take care of that in many cases.
In
const OFFSET = 3;
var Foo = React.createClass({
render: function () {
return (
<div tabIndex={OFFSET + 1} />
);
}
});
Out
const OFFSET = 3;
var _ref = <div tabIndex={OFFSET + 1} />;
var Foo = React.createClass({
render: function () {
return _ref;
}
});
Deopt
As noted in facebook/react#3226, it's not safe to reuse elements with mutable props.
<div style={
{ width: 100 }
} />