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
babel-generator
- #4979
babel-generator
: Expose raw mappings. (@davidaurelio)
- #4979
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
- #4873 Ensure directives get printed in block statements. (@existentialism)
let blockStatement = t.blockStatement(
[],
[t.directive(t.directiveLiteral("use strict"))]
);
babel-generator
,babel-helper-builder-react-jsx
,babel-plugin-transform-react-jsx
,babel-types
- #4988 Add
JSXSpreadChildren
but throw in JSX transform plugin. (@jridgewell)
- #4988 Add
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
- #3572 Fix default parameter - rest parameter edge case. (@jridgewell)
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
- #5007 Bail on sharing comments with siblings if key is a string. (@existentialism)
myLabel: //woops
for (let a of b) {
continue myLabel;
}
📝 Documentation
- Other
- #4989 Fix links in CONTRIBUTING.md. (@abouthiroppy)
babel-plugin-transform-runtime
babel-plugin-transform-es2015-unicode-regex
- #4983 Add example to es2015-unicode-regex. (@existentialism)
🏠 Internal
babel-helper-transform-fixture-test-runner
,babel-plugin-syntax-trailing-function-commas
Allows running require()
in exec.js tests like for babel/babel-preset-env#95
Committers: 7
- Brian Ng (existentialism)
- Dan Harper (danharper)
- David Aurelio (davidaurelio)
- Henry Zhu (hzoo)
- Justin Ridgewell (jridgewell)
- Scott Kyle (appden)
- Yuta Hiroto (abouthiroppy)