babel / kneden

Transpile ES2017 async/await to vanilla ES6 Promise chains: a Babel plugin
ISC License
514 stars 41 forks source link

preset-env: "await is a reserved word" #124

Open IngwiePhoenix opened 6 years ago

IngwiePhoenix commented 6 years ago

I tried getting this to work together with the @babel/preset-env package, but had no luck... Is Babel 7 not supported yet?

ljharb commented 6 years ago

It’s unlikely since his package hasn’t had a maintainer in awhile.

IngwiePhoenix commented 6 years ago

Too bad. I really don't want to use generators - partially because I dont know really how they work, and as I am targeting IE11 as well, I would probably need another transpilation step "just" for the generator stuff, whilst the rest of the code uses Promises.

Anyway, here is my .babelrc, maybe you can see the mistake that I don't.

{
  "presets": [
    ["@babel/env", {
      "targets": {
        "node": "current"
      }
    }]
  ],
  "plugins": [
    "babel-plugin-syntax-async-functions",
    "babel-plugin-async-to-promises",
    ["babel-plugin-module-resolver", {
      "alias": {
        "BIRD3": "./src"
      }
    }],
    ["@babel/plugin-proposal-class-properties", {
      "loose": true
    }],
    ["@babel/plugin-transform-react-jsx", {
      "pragma": "h",
      "pragmaFrag": "fragment",
      "throwIfNamespace": false
    }]
  ]
}

Note: I am testing transpiling on the CLI, and will later adapt to WebPack for more browser-specific settings and the like.

ljharb commented 6 years ago

Setting the target to current node won't work in IE 11; you probably want to dial that back a ways.

vivek12345 commented 5 years ago

@IngwiePhoenix From what I understand IE11 does not support promises. So you have two options now:- 1) Use bluebird 2) Use a babel plugin to translate promises or async await to generator functions which babel-preset-env already does.

ljharb commented 5 years ago

Or, use an actual promise shim (not bluebird) - either es6-shim or core-js.