43 Commits

Author SHA1 Message Date
Nicolò Ribaudo
d21e2217d5
Skip newlines around inline #__PURE__ annotations (#11133)
* Skip newlines around #__PURE__ annotations

* Update tests
2020-02-13 19:16:33 +01:00
Nicolò Ribaudo
99035ca96e
Don't use args rest/spread to hoist super method calls (#9939)
* Don't use args rest/spread to hoist super method calls

* Hoist this in hoisted super method calls

* Make the code more readable

Review by edoardocavazza
2019-10-11 10:18:54 +02:00
Nicolò Ribaudo
b8d045f5cf
Update regenerator-transform (#9558) 2019-02-21 23:24:31 +01:00
Nicolò Ribaudo
c11cdcb6d8
Fix recursive async function expressions (#9039)
* Fix recursive async function expressions

* Update fixtures
2018-11-19 17:19:54 +01:00
Logan Smyth
79b2af5997
Format fixture JSON with Prettier. (#8658) 2018-09-09 17:57:52 -07:00
Justin Ridgewell
e229ebbb8a
Optimize async to generator (#8267)
* Optimize async to generator

We can reuse the step function, avoiding a closure on every invocation.

* Rename step
2018-07-05 10:51:16 -04:00
Logan Smyth
7cc00cce0d Require output fixture extension to match sourceType output. 2018-03-04 13:31:33 -08:00
Logan Smyth
beb99dfda1 Rename test fixtures using module syntax to .mjs files. 2018-03-04 13:31:32 -08:00
Nicolò Ribaudo
8659e1a88c Remove old expected.{js,json} files (#7187) 2018-01-09 13:10:30 -06:00
Raja Sekar
0f42accb87 Renamed files 2018-01-09 15:36:42 +01:00
Diogo Franco
0f60d42fdf
Avoid adding #__PURE__ annotation to .bind(this)() expressions (#7043)
* Avoid adding #__PURE__ annotation to .bind(this)() expressions

Fixes the #__PURE__ annotation getting added to (async () => {})() IIFEs when the arrow function transform is running with spec: true.

* Return false instead of undefined

* Fix indentation in json files

* Add one more case to the async-iife fixtures
2017-12-28 17:02:54 +09:00
Nicolò Ribaudo
05b22d2597
Update @babel/helper-wrap-function templates (#6984)
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`).
2017-12-13 16:21:58 +01:00
Diogo Franco
82357d79a7 Workaround bad #__PURE__ annotation placement on IIFEs (#6999)
Based on a fix suggested by @kzc
2017-12-08 09:51:48 -05:00
Satyajit Sahoo
7ae6e1e5a0 Add /*#__PURE__*/ annotatiotion for babel-plugin-async-to-generator. Fixes #6572 2017-11-12 18:31:48 +05:30
Henry Zhu
9ac326b075
remove es20xx prefixes from plugins and rename folders (#6575) 2017-10-28 20:43:15 -04:00
Mateusz Burzyński
88b7983e4f Fixed asyncToGenerator helper using arrow function (#6289) 2017-09-21 17:09:43 -07:00
Pranav Prakash
e98bb3dc60 Use new Array instead of Array for V8 optimization (#6250)
* Use new Array instead of Array for V8 optimization

* fix spacing [skip ci]

* Remove extraneous use strict clauses
2017-09-18 14:14:46 -04:00
Henry Zhu
0f823beeb1 Newlines in fixtures (#6044)
* write newlines for fixtures

* rerun fixtures
2017-08-02 15:35:29 -04:00
Daniel Tschinder
b3372a572d Remove whitespace generation (#5833)
* 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
2017-06-27 21:57:02 -05:00
Logan Smyth
14584c218c Kill the "shadow-functions.js" internal plugin in favor of an explicit helper (#5677)
* Handle arrow function processing via shared API rather than default plugin.

* Fix a few small PR comments.

* Preserve existing spec arrow 'this' rewrites, and support spec in subclass constructors.
2017-05-05 13:27:18 -07:00
Steven Hargrove
d5aa6d3ff8 Fix for #4943 "Calling an async function with default parameter as function for arguments checking handled synchonous" (#5688)
* 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
2017-05-03 21:44:41 -07:00
Henry Zhu
2a874dff8c fix the fixtures after PR was merged 2017-04-06 14:14:15 -04:00
Diogo Franco
452f8f150c Always use the native (or polyfilled) Promise in transform-async-to-generator (#5536)
* Always use the native (or polyfilled) Promise in transform-async-to-generator

Fixes #5531

* Simplify scope handling to only un-shadow the Program's Promise

Only the helper needs to see the native Promise.
2017-04-06 11:17:31 -04:00
Logan Smyth
5aa87aab8d Calculate the correct arity for async functions with destructuring - fixes #4977 (#4978) 2016-12-08 21:51:24 -05:00
Logan Smyth
80dfdd2a43 Only base async fn arity on non-default/non-rest params - fixes #4891 (#4901) 2016-12-08 09:48:15 -05:00
lion
862b387ad7 👕 Fix crlf to lf (#4837) 2016-11-13 21:42:08 +01:00
Justin Ridgewell
15eeeb6559 Fix line endings (#4793) 2016-10-28 23:44:00 -04:00
zenparsing
26e79c5433 Implement support for async generator functions and for-await statements 2016-09-27 17:37:21 -04:00
Logan Smyth
231f27f170 Fix non-unique 'ref' binding name - fixes T7468 2016-06-28 19:16:44 -07:00
Logan Smyth
de21f2ef77 Resolve 'arguments' for rest args relative to direct parent. 2016-03-07 20:45:21 -08:00
Logan Smyth
42d3844f24 Revert special arrow wrapper and avoid shadowing arguments. 2016-03-07 20:45:20 -08:00
Logan Smyth
51ddeade8a Avoid renaming this bindings in simple arrow function cases. 2016-03-07 20:45:20 -08:00
keijokapp
105299f26d Fix named FunctionExpression scoping issue. 2016-02-29 19:21:48 +02:00
Erik
ec61bd9386 Revert "Don't mark async functions as hoist"
This reverts commit d34cb69912ee5789c7d1029c3be75d22d13e7bf8.
2016-02-02 22:13:26 -05:00
horpto
d0a932d0e8 [hotfix][T2765#72428] Wrong 'this' for nested arrow in arrow function 2016-01-22 10:29:04 +05:00
Amjad Masad
9980b6b8b2 [hotfix][T7006] Arrow functions don't have arguments bound 2016-01-20 00:41:17 -08:00
horpto
5ac022ab9b 4 -> 2 spaces tab size 2016-01-13 15:37:20 +05:00
horpto
fa9f8ea4be Fix for deeply nested async arrows 2016-01-11 04:37:16 +05:00
horpto
f2fdc74d1b [2765] transform-async-to-generator doesn't work for this inside arrow
function
2016-01-10 21:52:04 +05:00
Amjad Masad
0d8e5a9e86 Fix over-parenthesizing of function expressions 2015-12-24 14:55:51 -08:00
Sebastian McKenzie
1fa24b1efd rename babel-plugin-external-helpers-2 to babel-plugin-external-helpers 2015-12-24 03:54:40 +00:00
Sławomir Laskowski
d34cb69912 Don't mark async functions as hoist
`babel-template` no longer crashes in IE attempting to access unpopulated error stack
2015-11-29 01:47:24 +01:00
Sebastian McKenzie
15969a0904 move all plugin tests out of babel-core and into their appropriate folders 2015-11-08 23:04:10 -08:00