Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix async-to-generator ForAwait transform
The old transform called an external `babel-traverse`, which doesn鈥檛 does something funky.
- Loading branch information
1 parent
81e87b0
commit ceeb455
Showing
5 changed files
with
44 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
packages/babel-plugin-transform-async-to-generator/test/fixtures/regression/5880/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
(async () => { | ||
for await (const [value] of iterable) {} | ||
})() |
27 changes: 27 additions & 0 deletions
27
packages/babel-plugin-transform-async-to-generator/test/fixtures/regression/5880/expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
babelHelpers.asyncToGenerator(function* () { | ||
var _iteratorNormalCompletion = true; | ||
var _didIteratorError = false; | ||
var _iteratorError = undefined; | ||
|
||
try { | ||
for (var _iterator = babelHelpers.asyncIterator(iterable), _step, _value; _step = yield _iterator.next(), _iteratorNormalCompletion = _step.done, _value = yield _step.value, !_iteratorNormalCompletion; _iteratorNormalCompletion = true) { | ||
var _value2 = _value, | ||
_value3 = babelHelpers.slicedToArray(_value2, 1); | ||
|
||
const value = _value3[0]; | ||
} | ||
} catch (err) { | ||
_didIteratorError = true; | ||
_iteratorError = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion && _iterator.return) { | ||
yield _iterator.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError) { | ||
throw _iteratorError; | ||
} | ||
} | ||
} | ||
})(); |
8 changes: 8 additions & 0 deletions
8
...ages/babel-plugin-transform-async-to-generator/test/fixtures/regression/5880/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"plugins": [ | ||
"external-helpers", | ||
"transform-async-to-generator", | ||
"transform-es2015-destructuring", | ||
"syntax-async-generators" | ||
] | ||
} |