* Mark transpiled JSX elements as pure
* Avoid duble annotation
* Add "pure" option to the React preset
* Fix generator indentation
* Update tests
* Add tests for the "pure" option
* Update windows fixtures
Keeping the shape of an object constant is a performance improvement for modern javascript engines. At the point of the code change it is certain that the `children` property will be set later, so the property can already be set to `undefined`.
* add transform-class-properties to stage 3, set spec mode to default
* update readme with examples; use `buildUndefinedNode()`; change behavior to always define both static and nonstatic class properties regardless of spec/loose mode; update tests
* Remove whitespace generation and rely on default printing
Changes to printing:
* Add newline after last empty SwitchCase
* Add newlines around block comments if they are non-flow comments or contain newlines
* Fix a few more fixtures
* moved applying arguments inside new Promise handler block
* updated test fixture to reflect change
* corrected the apply to use correct scope and arguments
* added regression test for issue #4943, added async-to-generator/async-default-arguments test
* added regression test for issue #4943
* switched back to using arrow function, since now pointing to v7 release base branch
* simplified async-to-generator regression test for issue #4943, imrproved change to self/arguments refs by using arrow function on returned promise
* updated text fixtures
* removed es2015 preset usage from issue #4943 regression exec test
* added use strict to test fixture
* added use strict to test fixture
* added destructing transform to test options
* removed use strict from exec test
* added parameters & destructing transforms to test
When you write
```
for (const x of l) {
setTimeout(() => x);
}
```
we need to add a closure because the variable is meant to be block-scoped and recreated each time the block runs. We do this.
However, we also add the closure when no loop is present. This isn't necessary, because if no loop is present then each piece of code runs at most once. I changed the transform to only add a closure if a variable is referenced from within a loop.
The PathHoister ignored member references on "this", causing it
to potentially hoist an expression above its function scope.
This patch tells the hoister to watch for "this", and if seen,
mark the nearest non-arrow function scope as the upper limit
for hoistng.
This fixes#4397 and is an alternative to #4787.
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.
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.
- Have the `jsx` helper do the `defaultProps` work instead of calling `defaultProps` inline.
- Put `key` after `props` and make it optional.
- Inline `children` as rest args instead of in the object.
- Rename `createRawReactElement` to `jsx`. I wish I was kidding.
Most of these are silly microoptimizations. In my test file (based off an internal RN app), this reduces the parsing overhead of inlining from around 1% to 0.1% in JSC and from 0.6% to 0.0% in V8 (compared to element inlining before this commit).
Once parsed, the initial render with inlining is the same speed as not inlining in JSC and ~1% slower in V8. A second initial render in the same context (reusing the function objects, JIT, etc) is 2.0% faster in JSC and 5.5% faster in V8.
Either due to lower parsing costs or better type inference, this seems
to perform better than direct object inlining. (All along, the main win
was skipping a loop through props, not avoiding a function call.)