v6.19.0 (2016-11-16)
🚀 New Feature
babel-plugin-transform-object-rest-spread
This rewrite fixes a long standing issue where the object-rest-spread plugin was depending on 2 other plugins to compile RestProperty
. This is important given the assumption that plugins should be independent and is vital for the use of babel-preset-env since new environments support destructuring natively.
RestProperty
- Parameters
function a({ b, ...c }) {}
- VariableDeclaration
const { a, ...b } = c;
- ExportNamedDeclaration
export var { a, ...b } = c;
- CatchClause
try {} catch ({a, ...b}) {}
- AssignmentExpression
({a, ...b} = c);
- ForXStatement
for ({a, ...b} of []) {}
SpreadProperty
- ObjectExpression
var a = { ...b, ...c }
babel-plugin-transform-class-properties
Usage
{
"plugins": [
["transform-class-properties", {
"spec": true
}]
]
}
- Class properties are compiled to use
Object.defineProperty
- Static fields are now defined even if they are not initialized
In
class Foo {
static bar;
}
Out
var Foo = function Foo() {
babelHelpers.classCallCheck(this, Foo);
};
Object.defineProperty(Foo, "bar", {
enumerable: true,
writable: true,
value: undefined
});
We've added 2 similar "ancestry" path methods to path.findParent
:
path.isAncestor
/path.isDescenant
Usage:
let programPath, numberPath;
traverse(ast, {
Program(path) { programPath = path; },
NumberPath(path) { numberPath = path; },
});
programPath.isAncestor(numberPath); // true
numberPath.isDescendant(programPath); // true
Usage:
traverse.clearCache(); // clears both path's and scope cache
traverse.clearCache.clearPath();
traverse.clearCache.clearScope();
Usage:
{
"generatorOpts": {
"jsonCompatibleStrings": true // defaults to false
}
}
Set to true for the generator to use jsesc
with "json": true
. This will make it print "\u00A9"
vs. "©"
;
- #3547 Added
flowUsesCommas
option for object types. (@sampepose)
Usage:
{
"generatorOpts": {
"flowCommaSeparator": true // defaults to false
}
}
Currently there are 2 supported syntaxes (,
and ;
) in Flow Object Types. The use of commas is in line with the more popular style and matches how objects are defined in Javascript, making it a bit more natural to write.
var a: { param1: number; param2: string }
var a: { param1: number, param2: string }
t.isNodesEquivalent
Usage:
assert(t.isNodesEquivalent(parse("1 + 1"), parse("1+1")) === true);
babel-plugin-transform-es2015-modules-systemjs
- #4789 Support
import()
as contextual import in system module format. (@guybedford)
- #4789 Support
Support stage-2 import()
in systemjs.
It does not compile by default; you'll want to add the stage-2 preset or explicitly include babel-plugin-syntax-dynamic-import
.
export function lazyLoadOperation () {
return import('./x')
.then(function (x) {
x.y();
});
}
🐛 Bug Fix
Will print the shorter of the NumericLiteral
s if using the minified
option.
Input
5e1;
5e4;
Output
50;
5e4;
babel-plugin-transform-es2015-modules-systemjs
- #4832 Fix system transformer to ensure consistent modules iteration. (@guybedford)
Fixes inconsistent modules iteration for numeric imports
import "2"; // should be imported first
import "1"; // second
babel-plugin-transform-es2015-destructuring
,babel-plugin-transform-react-constant-elements
Fixes an issue with destructuring parameters being hoisted incorrectly.
Input
function render({ text }) {
return () => (<Component text={text} />);
}
Output
function render(_ref) {
let text = _ref.text;
var _ref2 = <Component text={text} />;
return () => _ref2;
}
📝 Documentation
🏠 Internal
babel-plugin-transform-async-to-generator
- #4837 Fix crlf to lf. (@lion-man44)
- Other
Committers: 10
- Boopathi Rajaa (boopathi)
- Guy Bedford (guybedford)
- Henry Zhu (hzoo)
- Juriy Zaytsev (kangax)
- Moti Zilberman (motiz88)
- Sam Pepose (sampepose)
- Samuel Reed (STRML)
- Scott Stern (sstern6)
- Shine Wang (shinew)
- lion (lion-man44)