@babel/plugin-transform-async-to-generator

    In

    1. var _asyncToGenerator = function (fn) {
    2. ...
    3. };
    4. var foo = _asyncToGenerator(function* () {
    5. });

    Out with options

    1. var Bluebird = require("bluebird");
    2. var foo = Bluebird.coroutine(function*() {
    3. });

    Without options:

    1. {
    2. "plugins": ["@babel/plugin-transform-async-to-generator"]
    3. }
    1. {
    2. "plugins": [
    3. [
    4. "@babel/plugin-transform-async-to-generator",
    5. "module": "bluebird",
    6. }
    7. ]
    8. ]
    9. }
    1. require("@babel/core").transformSync("code", {
    2. plugins: ["@babel/plugin-transform-async-to-generator"],
    3. });

    When using await with non-promise values, Bluebird will throw “Error: A value was yielded that could not be treated as a promise”. Since Babel cannot automatically handle this runtime error, you should manually transform it to a promise.

    1. async function foo() {
    2. - await 42;
    3. }