This commit introduces 4 changes:
1) Function declarations are wrapped using function declarations.
This has two advantages:
- We can rely on native hoisting, instead of using _blockHoist
- The function isn't wrapped until it is called. This avoids
problems where `regeneratorRuntime.wrap` was called before
that `babel-polyfill` was imported.
Example:
function fn() {}
// becomes
function fn() { return _fn.apply(this, arguments); }
function _fn() {
_fn = _wrapper(/* Original function ... */);
return _fn.apply(this, arguments);
}
2) Use a single template for both named and anonymous function
expressions. They already had the same behavior, but the one
used for named functions was a bit longer.
3) Use normal functions instead of arrow functions to wrap
function expressions.
4) Generate a name based on the original one for wrapped
functions (e.g. `foo` becomes `_foo` instead of `_ref`).
* update lerna and lerna-changelog
* Lerna: enable yarn, yarn workspaces [skip ci]
* use older version of Babel since it matches on semver (cannot be the same version)
* install yarn version
* revert node engine change
* update flow
* circle ci on 8
* update lock
* Create "babel-helper-wrap-function"
It contains the logic to wrap a function inside a call expression.
It was part of the "babel-helper-remap-async-to-generator" package, but
it is needed to transpile "function.sent"
* Create "babel-transform-function-sent"
It transforms the "function.sent" meta property by replacing it with
"yield" and making the generator ignore the first ".next()" call.
* "function.sent" is the last value passed to .next(), not the first one
* Disable exec tests on old node
* Fix flow error
* Add "transform-function-sent" to "stage-2" preset
* Do every trasformation in one traversal
* Test for "yield function.sent"
* [skip ci]
* Fix some typos [skip ci]