v6.22.2

@hzoo hzoo released this Jan 20, 2017 · 5 commits to master since this release

6.22.2 (2017-01-19)

πŸ› Bug Fix

  • babel-cli
    • Fix issue with babel-node throwing errors when passed non-"-" args #5162.

Downloads

v6.22.1

@hzoo hzoo released this Jan 20, 2017 · 9 commits to master since this release

6.22.1 (2017-01-19)

πŸ› Bug Fix

Temporary fix with babel-traverse via #5019 for transform-react-constant-elements.

Downloads

v6.22.0

@hzoo hzoo released this Jan 20, 2017 · 12 commits to master since this release

6.22.0 (2017-01-19)

Thanks to 10 new contributors! (23 total)

A quick update since it's been over a month already: adds support for shorthand import syntax in Flow + some fixes!

We'll be merging in our current 7.0 PRs on a 7.0 branch soon and I'l be making some more issues (most should be beginner-friendly).

To follow our progress check out our 7.0 milestone, the wiki and upcoming announcements on twitter!

We support stripping out and generating the new shorthand import syntax in Flow (parser support was added in babylon@6.15.0.

import {
  someValue,
  type someType,
  typeof someOtherValue,
} from "blah";

πŸš€ New Feature

  • babel-generator, babel-types
  • babel-plugin-transform-flow-strip-types, babel-traverse
    • #5035 Strip Flow's new shorthand import-type specifiers. (@jeffmo)
  • babel-core
    • #4729 Add resolvePlugin and resolvePreset methods to babel-core API. (@rmacklin)

πŸ› Bug Fix

  • babel-plugin-transform-object-rest-spread
const { x, ...y } = foo();

Old Behavior

const { x } = foo();
const y = _objectWithoutProperties(foo(), ["x"]);

New/Expected Behavior

const _ref = foo(); // should only be called once
const { x } = _ref; 
const y = _objectWithoutProperties(_ref, ["x"]);
  • babel-cli
  • babel-plugin-transform-object-rest-spread

Accounts for default values in object rest params

function fn({a = 1, ...b} = {}) {
  return {a, b};
}
  • babel-plugin-transform-es2015-destructuring
const assign = ([...arr], index, value) => {
  arr[index] = value
  return arr
}

const arr = [1, 2, 3]
assign(arr, 1, 42)
console.log(arr) // [1, 2, 3]
  • babel-plugin-transform-es2015-function-name
    • #5008 Don't try to visit ArrowFunctionExpression, they cannot be named. (@Kovensky)

Input

export const x = ({ x }) => x;
export const y = function () {};

Output

export const x = ({ x }) => x;
export const y = function y() {}; 
  • babel-types
    • #5068 Fix getBindingIdentifiers in babel-types. (@rtsao)
  • babel-cli
    • #3698 Watch mode should wait for file write. (T7411) (@hayeah)

πŸ’… Polish

  • babel-traverse
    • #5076 Optimize removal-hooks for ArrowFunctions. (@danez)
  • babel-generator, babel-plugin-transform-exponentiation-operator

πŸ“ Documentation

  • Other
  • babel-core
  • babel-plugin-syntax-class-constructor-call
    • #5130 update syntax-class-constructor-call documentation. (@xtuc)
  • babel-plugin-transform-es2015-duplicate-keys, babel-plugin-transform-es2015-parameters
    • #5111 Fixes some inconsistent documentation. (@xtuc)
  • babel-plugin-transform-es2015-computed-properties, babel-plugin-transform-es2015-for-of
  • babel-plugin-transform-class-properties
    • #5077 Static function call result comment does not match variable content [skip ci]. (@kasn)
  • Other
  • babel-plugin-transform-es2015-classes, babel-plugin-transform-function-bind
  • babel-helpers
    • #5059 Fix incorrect snippet language in babel-helpers. (@xtuc)
  • babel-preset-react
  • babel-plugin-check-es2015-constants, babel-plugin-transform-es2015-modules-umd, babel-plugin-transform-es2015-typeof-symbol, babel-register
  • babel-core

🏠 Internal

  • babel-*
  • babel-helper-transform-fixture-test-runner
  • babel-cli, babel-core, babel-generator, babel-helper-define-map, babel-register, babel-runtime, babel-types
    • #5043 Replace "lodash/is*" and "lodash/each" with native equivalents. (@zertosh)
  • babel-cli, babel-generator, babel-helper-fixtures, babel-helper-transform-fixture-test-runner, babel-preset-es2015, babel-runtime, babel-traverse
    • #5042 Use native or lodash util module where full "lodash" is required. (@zertosh)
  • babel-code-frame
  • babel-plugin-transform-react-jsx
  • babel-plugin-transform-decorators
  • babel-plugin-transform-es2015-computed-properties
  • babel-cli

Committers: 23, First PRs: 10

Downloads

v6.21.1

@loganfsmyth loganfsmyth released this Dec 18, 2016 · 90 commits to master since this release

6.21.1 (2016-12-17)

πŸ› Bug Fix

  • babel-helper-builder-react-jsx, babel-plugin-transform-react-jsx
    • #5015 Revert the introduction of a new error message that ended up introducing its own error (@loganfsmyth)

Downloads

v6.21.0

@hzoo hzoo released this Dec 16, 2016 · 94 commits to master since this release

6.21.0 (2016-12-16)

Mostly a lot of bug fixes + exposing rawMapping in babel-generator for easy source map use.

Thanks to davidaurelio, appden, and abouthiroppy for their first PRs!

πŸš€ New Feature

Exposes raw mappings when source map generation is enabled. To avoid the cost of source map generation for consumers of the raw mappings only, .map is changed to a getter that generates the source map lazily on first access.

Raw mappings can be useful for post-processing source maps more efficiently by avoiding one decoding/encoding cycle of the b64 vlq mappings. This will be used in the React Native packager.

let generator = require("babel-generator");
let generated = generator(ast, { sourceMaps: true }, sources);

// generated.rawMappings
[
  {
    name: undefined,
    generated: { line: 1, column: 0 },
    source: "inline",
    original: { line: 1, column: 0 }
  },
  ...
]

πŸ› Bug Fix

  • babel-generator, babel-plugin-transform-flow-comments, babel-plugin-transform-flow-strip-types
    • #4872 Print Flow optional & type annotations in function params with defaults. (@danharper)

Works with generator, transform-flow-comments, flow-strip-types.

function foo(numVal: number = 2) {}
  • babel-generator, babel-plugin-transform-es2015-modules-amd, babel-plugin-transform-es2015-modules-umd
let blockStatement = t.blockStatement(
  [],
  [t.directive(t.directiveLiteral("use strict"))]
);
  • babel-generator, babel-helper-builder-react-jsx, babel-plugin-transform-react-jsx, babel-types

Will still error with Spread children are not supported.

<div>{...this.props.children}</div>;
  • babel-plugin-transform-es2015-block-scoping, babel-plugin-transform-react-constant-elements, babel-traverse

When multiple declarators are present in a declaration, we want to insert the constant element inside the declaration rather than placing it before because it may rely on a declarator inside that same declaration.

function render() {
  const bar = "bar", renderFoo = () => <foo bar={bar} baz={baz} />, baz = "baz";

  return renderFoo();
}

When block scoped variables caused the block to be wrapped in a closure, the variable bindings remained in parent function scope, which caused the JSX element to be hoisted out of the closure.

function render(flag) {
  if (flag) {
    let bar = "bar";

    [].map(() => bar);

    return <foo bar={bar} />;
  }

  return null;
}
  • babel-plugin-transform-es2015-parameters

Was erroring if the rest parameter shared the same name as a default identifier for a param, needed to be deopt'd.

const a = 1;
function rest(b = a, ...a) {
  assert.equal(b, 1);
}
rest(undefined, 2)
  • babel-plugin-transform-es2015-for-of, babel-traverse
myLabel: //woops
for (let a of b) {
  continue myLabel;
}

πŸ“ Documentation

  • Other
  • babel-plugin-transform-runtime
    • #4991 make installing runtime/transform-runtime clearer [skip ci]. (@hzoo)
  • babel-plugin-transform-es2015-unicode-regex

🏠 Internal

  • babel-helper-transform-fixture-test-runner, babel-plugin-syntax-trailing-function-commas
    • #4999 babel-helper-transform-fixture-test-runner: pass require as a global. (@hzoo)

Allows running require() in exec.js tests like for babel/babel-preset-env#95

  • Other
    • #5005 internal: don't run watch with the test env (skip building with code …. (@hzoo)

Committers: 7

Downloads

v6.20.3

@hzoo hzoo released this Dec 9, 2016 · 122 commits to master since this release

v6.20.3 (2016-12-08)

😒 Regression

  • babel-plugin-transform-async-to-generator

Downloads

v6.20.2

@hzoo hzoo released this Dec 9, 2016 · 124 commits to master since this release

v6.20.2 (2016-12-08)

😒 Regression

Issue: #4972 again. Fixed by reverting part of the original PR in babel/babel#4883.

Downloads

v6.20.1

@hzoo hzoo released this Dec 9, 2016 · 128 commits to master since this release

v6.20.1 (2016-12-08)

😒 Regression

Issue: #4972

The way that babel/babel#4883 changed visiting SpreadProperty (which didn't need to modified) caused an infinite loop. Added path.stop which ended up not fixing it correctly.

Downloads

v6.20.0

@hzoo hzoo released this Dec 8, 2016 · 130 commits to master since this release

v6.20.0 (2016-12-08)

If you missed it, please check out our latest blog post: The State of Babel. It talks about where we can possibly move forward as a project and how you can help!

Also just wanted to reiterate that Babel is a community-lead project that is run by volunteers - many of us came into the project to learn about JavaScript rather than because we knew it already. Let's work together to make it sustainable!


You've probably seen this more than a few times and had no idea what it meant...

[BABEL] Note: The code generator has deoptimised the styling of "app.js" as it exceeds the max of "100KB".

Generating code used to get really slow as file size increased. We've mostly fixed that, but we still automatically fall back to compact output on large files. We're going to bump the limit to 500KB and if there aren't issues just remove it.


Ben Newman, @benjamn: wrote Regenerator while at Facebook. It used a bunch of other libraries such as ast-types but has now been rewritten as a standalone Babel plugin (also thanks to Sebastian's previous work in facebook/regenerator#222). We're also moving the implementation of Regenerator back into the original repository since Ben is the creator/maintainer.

πŸš€ New Feature

  • babel-traverse
    • #4876 Add getBindingIdentifierPaths/getOuterBindingIdentifierPaths. (@boopathi)

Returns Array<Path> rather than Array<Node>.

  • path.getBindingIdentifierPaths()
  • path.getOuterBindingIdentifierPaths()
traverse(parse(`
  var a = 1, {b} = c, [d] = e, function f() {};
`), {
  VariableDeclaration(path) {
    let nodes = path.getBindingIdentifiers(); // a, d, b
    let paths = path.getBindingIdentifierPaths();
  },
  FunctionDeclaration(path) {
    let outerNodes = path.getOuterBindingIdentifiers(); // f
    let outerPaths = path.getOuterBindingIdentifierPaths();
  }
});
  • babel-code-frame
    • #4913 Add forceColor option to babel-code-frame. (@Timer)

Forcibly syntax highlight the code as JavaScript (for non-terminals); overrides highlightCode. For facebookincubator/create-react-app#1101

Usage

const result = codeFrame(rawLines, lineNumber, colNumber, {
  forceColor: true
});

πŸ› Bug Fix

  • babel-plugin-transform-es2015-block-scoping
    • #4880 Add (and fix) failing test of function parameter bindings in a catch block. (@benjamn)

In

try {
  foo();
} catch (x) {
  function harmless(x) {
    return x;
  }
}

Correct Out

try {
  foo();
} catch (x) {
  var harmless = function (x) {
    return x;
  };
}
  • babel-helper-remap-async-to-generator, babel-plugin-transform-async-generator-functions, babel-plugin-transform-async-to-generator
// both length's should be 0
const foo = (...args) => { }
console.log(foo.length)  // 0
const asyncFoo = async (...args) => { }
console.log(asyncFoo.length)  // 0
  • babel-generator, babel-types

Relevant for webpack 2 support of Import. Just allows Babel to print it correctly.

import("module.js");
  • babel-plugin-transform-object-rest-spread
function a5({a3, b2: { ba1, ...ba2 }, ...c3}) {}
  • babel-traverse
    • #4875 Fix path.evaluate for references before declarations. (@boopathi)
// should deopt if ids are referenced before the bindings
var a = b + 2; var b = 2 + 2;
  • babel-core, babel-generator, babel-helper-transform-fixture-test-runner, babel-plugin-transform-object-rest-spread
    • #4858 Fix bug + Generate test fixtures if no expected.js. (@hzoo)
  • babel-types

πŸ’… Polish

πŸ“ Documentation

🏠 Internal

  • babel-plugin-transform-regenerator
    • #4881 Use regenerator-transform to implement babel-plugin-transform-regenerator. (@benjamn)
  • babel-traverse
  • babel-polyfill
  • babel-runtime
    • #4877 Upgrade regenerator-runtime to version 0.10.0. (@benjamn)
  • babel-plugin-syntax-trailing-function-commas
  • babel-helper-fixtures
  • babel-core, babel-traverse
  • babel-generator

Committers: 17

Downloads

v6.19.0

@hzoo hzoo released this Nov 16, 2016 · 180 commits to master since this release

v6.19.0 (2016-11-16)

πŸš€ New Feature

  • babel-plugin-transform-object-rest-spread
    • #4755 Make the plugin work standalone with parameters/destructuring plugins. (@hzoo)

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
    • #4544 Greater spec compliance for class properties with the new spec option. (@motiz88)

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
});
  • babel-traverse

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
  • #4835 Add clearCache and clearPath as separate APIs under traverse. (@boopathi)

Usage:

traverse.clearCache(); // clears both path's and scope cache
traverse.clearCache.clearPath();
traverse.clearCache.clearScope();
  • babel-generator
    • #4827 Add jsonCompatibleStrings option to generator. (@kangax)

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. "Β©";

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 }
  • babel-types
    • #3553 Start babel-types tests, add isNodesEquivalent. (@hzoo)

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)

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

  • babel-generator

Will print the shorter of the NumericLiterals 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
    • #4813 Fix binding kind of destructured variables.. (@STRML)

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
  • Other
    • #4807 Chore: FLOW command in makefile and logic in .travis.yml(issue#4710).. (@sstern6)

Committers: 10

Downloads