Skip to content

v6.5.0

Compare
Choose a tag to compare
@hzoo hzoo released this 07 Feb 03:05
· 9770 commits to main since this release

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
  • babel-core
    • #3281 passPerPreset option in .babelrc: if true, babel will create a new traversal for each preset. (@DmitrySoshnikov)
  • babel-helper-transform-fixture-test-runner, babel-plugin-transform-react-jsx-source
    • #3285 Hoist the current file name (an absolute path) for transform-react-jsx-source . (@frantic)

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
  • babel-core
    • #3313 Add babel.analyze - an api sugar for getting back metadata from babel. (@kittens)
// analyse not analyze :D
// usage
babel.analyse("foobar;", {}, {
  Program: function (path) {
    path.mark("category", "foobar");
  }
}).marked[0].message // outputs "foobar"
  • babylon
    • #3319 Add support for leading pipes in Flow type alias RHS syntax (@jeffmo)
// 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
    • #3298 Set NOT_LOCAL_BINDING symbol on all inferred function names. (issue T7010, regression of #3274) (@amasad)
// 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
// 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 with babel-template. (Issue T6903) (@guybedford)
  • 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
    • #3311 Consider arrow functions when parenthesizing object expressions. (Issue T7047) (@amasad)
var fn = () => ({}).key;
  • babel-helper-remap-async-to-generator, babel-plugin-transform-es2015-modules-commonjs
foo();

async function foo() {} // this should be hoisted above foo();
  • babel-generator
    • #3324 Parenthesize the in in a for-loop init, even in the case when it is nested. (@zjmiller)
// nested for loop
for (function(){for(;;);} && (a in b);;);
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 and Pattern interfaces, update Identifier interface. (@jmm)

Internal

  • #3317 make publish: add make build in case it wasn't run. (@hzoo)
  • babel-generator
  • babel-core, babel-generator, babel-traverse, babel-types,babylon
    • #3186 Add more flow types, update flow, eslint, babel-eslint, only run flow on node 5. (@hzoo)
  • 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
    • #3307 Make the chokidar dependency optional. (@josh)
  • babel-types
    • #3294 WithStatements can have statements as bodies. (@amasad)
  • babel-types

Polish