npm babel-traverse 6.21.0
v6.21.0

latest releases: 7.0.0-beta.3, 7.0.0-beta.2, 7.0.0-beta.1...
7 years ago

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

Don't miss a new babel-traverse release

NewReleases is sending notifications on new releases.