@amasad amasad released this Mar 9, 2016 · 5132 commits to master since this release

Assets 2

6.7.0 (2016-03-08)

Notable changes:

  • Various async function fixes (const read-only error, wrong this, etc)
  • Proper sourcemaps for import/export statements
  • Moved internal Babel cache out of the AST

New Feature

  • babel-traverse

Move cache into a clearable WeakMap, adds traverse.clearCache and traverse.copyCache. This doubles as a bug fix because previously reusable AST Nodes would carry their cache with them even if they're used across multiple files and transform passes.

  • babel-generator, babel-plugin-transform-flow-comments, babel-plugin-transform-flow-strip-types, babylon
// examples
class C<+T,-U> {}
function f<+T,-U>() {}
type T<+T,-U> = {}

This syntax allows you to specify whether a type variable can appear in
a covariant or contravariant position, and is super useful for, say,
Promise. @samwgoldman can tell you more 😄.

  • babel-generator, babylon
    • #3323 Source-map support for multiple input source files. (@divmain)

More docs on this in the babel-generator README

Bug Fix

  • babel-traverse

Make sure all existing let/const bindings are removed and replaced with vars after the block-scoping plugin is run.

This fixes: SyntaxError: src/foo.js: "baz" is read-only (This is an error on an internal node. Probably an internal error. Location has been estimated.)

async function foo() {
  async function bar() {
    const baz = {}; // was creating a read-only error
  }
}
  • babel-core, babel-traverse, babel-helper-remap-async-to-generator, babel-helper-replace-supers, babel-plugin-transform-async-to-generator, babel-plugin-transform-async-to-module-method

Should fix the majority of issues dealing with async functions and use of parameters, this, and arguments.

// fixes
class Test {
  static async method2() {
    setTimeout(async (arg) => {
      console.log(this); // was showing undefined with arg
    });
  }

  async method2() {
    setTimeout(async (arg) => {
      console.log(this); // was showing undefined with arg
    });
  }
}
  • babel-helper-remap-async-to-generator, babel-plugin-transform-async-to-generator, babel-plugin-transform-async-to-module-method

The problem is that the name bar of FunctionExpression is only visible inside that function, not in foo or ref.

// input
var foo = async function bar() {
  console.log(bar);
};


// before
var foo = function () {
  var ref = babelHelpers.asyncToGenerator(function* () {
    console.log(bar);
  });

  return function bar() {
    return ref.apply(this, arguments);
  };
}();

// now
var foo = function () {
  var ref = babelHelpers.asyncToGenerator(function* () {
    console.log(bar);
  });

  function bar() {
    return ref.apply(this, arguments);
  }

  return bar
}();
  • babel-plugin-transform-es2015-parameters

Many fixes to rest params: function asdf(...rest) { ... }

  • babel-template
  • babel-plugin-transform-es2015-modules-commonjs
    • #3409 Fix source map generation for import and export statement.

Internal

  • babel-plugin-transform-es2015-modules-commonjs
    • #3383 Test for regression with exporting an arrow function with a default param. (@hzoo)

Commiters: 6

amasad, divmain, hzoo, jmm, keijokapp, loganfsmyth, samwgoldman