MatAtBread / fast-async

605 stars 21 forks source link

generators:false not honored - still outputs code using generators #67

Closed rjgotten closed 4 years ago

rjgotten commented 4 years ago

Even when specifying generators:false a source function

(async () => {
  await Promise.all([a, b]);
  console.log("ready");
});

generates

(function* () {
  yield Promise.all([a, b]);
  console.log("ready");
})();

which continues to use generators.

Using fast-async 7.0.6

verydanny commented 4 years ago

This is because you have to disable the generator options in @babel/preset-env. Like so:

module.exports = {
  presets: [
    ['@babel/env', {
      modules: false,
      targets: {
        browsers: ['last 2 Chrome versions'],
      },
      exclude: [
        'transform-async-to-generator',
        'transform-regenerator',
      ],
    }],
  ],
  plugins: [
    ['module:fast-async', {
      spec: true,
    }],
  ],
}
rjgotten commented 4 years ago

Yup. I just noticed this myself as well. The config I was working off of, was only disabling regenerator, and not the actual async-to-generator transformation. Doh! (Of all the stupid oversights...)

Closing this, as it's invalid.