6.5.0 (2016-02-07)
Happy Superbowl Sunday! There's many contributors (17 + core) this release!
A traversal per preset (Experimental)
This is an experimental feature that will almost certainly change. You should use this option in specific cases while we figure out a better way to do this.
Depending on usage/feedback, we will switch the way this is used to instead define a explicit preset-level config flag (rather than the global one below). This will give more control over how you want to use this option.
{
passPerPreset: true,
presets: [
{
plugins: ['plugin-1']
},
'preset-2',
{
plugins: ['plugin-2']
}
]
}
// this will create 3 traversals
Thanks to @DmitrySoshnikov, passPerPreset: true
will modify how babel traverses through plugins. Instead of a single traversal in which all plugins/presets are merged together, each preset will get their own traversal.
This allows users to have a specific order to how presets/plugins are applied and can help avoid potential collisions between plugins (and probably some known issues).
More Speeeeeeed
@gzzhanghao made some awesome changes to improve our code generator's performance (babel-generator
). The original issue is here.
Based on his test (on parsing jquery.js
), performance improved ~3x.
===== origin/master (ms) =====
babylon 265
babel generator 2238 <-- old
acorn 107
escodegen 355
esprima 95
escodegen 322
===== Optimized (ms) =====
babylon 296
babel generator 662 <-- new
acorn 113
escodegen 355
esprima 106
escodegen 317
A big change had to do with keeping this.last
as an instance variable in the buffer instead of this.buf[this.buf.length -1]
.
You can read more about his changes here. Hoping to see more PR's like this!
We will try to setup some perf tests soon to track these stats for the future (or you can help!).
New Feature
babel-core
- #3168 Use the
babelrc
option inbabel-register
. (@CrocoDillon)
- #3168 Use the
babel-core
- #3281
passPerPreset
option in.babelrc
: iftrue
, babel will create a new traversal for each preset. (@DmitrySoshnikov)
- #3281
babel-helper-transform-fixture-test-runner
,babel-plugin-transform-react-jsx-source
This plugin (useful for tooling) will turn
// this/file.js
<sometag />
into
var _jsxFileName = "this/file.js"; // the output will be an absolute path
var x = <sometag __source={{
fileName: _jsxFileName,
lineNumber: 1
}} />;
babel-template
- #3304 Allow passing in
babylon
options intobabel-template
. (issue T7046) (@jamestalmage)
- #3304 Allow passing in
babel-core
// analyse not analyze :D
// usage
babel.analyse("foobar;", {}, {
Program: function (path) {
path.mark("category", "foobar");
}
}).marked[0].message // outputs "foobar"
// allows for either `|` or `&`
type union =
| {type: "A"}
| {type: "B"}
;
This was added in flow in
7fb56ee9d8
.
Bug Fix
Code samples below each bullet
babel-helper-define-map
,babel-helper-function-name
,babel-plugin-transform-es2015-classes
// When the same name as a method in a class is used
class Foo {
constructor(val) {
this._val = val;
}
foo2() {
return foo2(this._val); // was erroring since foo2 is used
}
}
babel-helper-remap-async-to-generator
,babel-plugin-transform-async-to-generator
- #3297 Fixes the wrong
this
for nested arrow functions. (Issue T2765#72428) (@horpto)
- #3297 Fixes the wrong
// nested arrow functions
class A {
async method() {
() => {
() => this; // `this` in nested arrow function was incorrect
}
}
}
babel-template
- #3314 Only strip node info if no
node.loc
. Fixes an issue with sourcemap generation for SystemJS withbabel-template
. (Issue T6903) (@guybedford)
- #3314 Only strip node info if no
babel-traverse
- #3300 Fix an issue with transpiling generator functions with default arguments. (Issue T2776) (@gzzhanghao)
// a generator with a default argument
export class Test {
*memberGenerator(arg = 0) {
console.log(arg);
}
start() {
this.memberGenerator(1).next();
}
}
babel-generator
var fn = () => ({}).key;
babel-helper-remap-async-to-generator
,babel-plugin-transform-es2015-modules-commonjs
- #3312 Fix async functions not being hoisted. (Issue T6882) (@erikdesjardins)
foo();
async function foo() {} // this should be hoisted above foo();
babel-generator
// nested for loop
for (function(){for(;;);} && (a in b);;);
babylon
- #3305 Fix: Arrow functions with trailing comma + return type parsing error. (Issue T7052) (@jviereck)
const X = (
props: SomeType,
): ReturnType => (
3
);
Documentation
- #3321 Docs: add information on writing tests in babylon. (@hzoo)
- #3308 Update compiler-environment-support.md. (@sappharx)
- #3293 ast/spec: update
Decorator
property. (@hzoo) - #3295 ast/spec: add
BindExpression
. (@hzoo) - #3287 Correct use of possessive case. (@nettofarah)
- #3301 ast/spec: add
Literal
andPattern
interfaces, updateIdentifier
interface. (@jmm)
Internal
- #3317
make publish
: addmake build
in case it wasn't run. (@hzoo) babel-generator
babel-core
,babel-generator
,babel-traverse
,babel-types
,babylon
babel-core
babel-plugin-transform-async-to-generator
babel-generator
- #3299 Add a test to ensure that we do not break mutli-byte handling. (@robcolburn)
babel-cli
babel-types
babel-types
Polish
babel-generator
- #3283 Improve generator performance. (Issue T6884) (@gzzhanghao)