Skip to content
This repository has been archived by the owner on Jun 10, 2019. It is now read-only.

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

Open
IngwiePhoenix opened this issue Nov 8, 2018 · 5 comments
Open

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

IngwiePhoenix opened this issue Nov 8, 2018 · 5 comments

Comments

@IngwiePhoenix
Copy link

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

@ljharb
Copy link
Member

ljharb commented Nov 8, 2018

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

@IngwiePhoenix
Copy link
Author

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
Copy link
Member

ljharb commented Nov 8, 2018

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

@vivek12345
Copy link

@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
Copy link
Member

ljharb commented Jan 29, 2019

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants