wbyoung / babel-plugin-transform-postcss

Babel PostCSS Transform
MIT License
55 stars 23 forks source link

Unexpected token function for `async` #33

Closed bzang closed 7 years ago

bzang commented 7 years ago

When I try using the transform I get the following when running with Node 6:

/node_modules/babel-plugin-transform-postcss/dist/postcss-server.js:56
const main = async function main(socketPath, tmpPath) {
                   ^^^^^^^^
SyntaxError: Unexpected token function

I don't have any issues when running with Node 7, but our current architecture doesn't quite support 7 yet. Any thoughts on how I can get around this?

My .babelrc:

{
  "plugins": [
    ["babel-plugin-transform-builtin-extend", {
        "globals": ["Error"]
    }],
    ["transform-runtime", {
      "polyfill": false
    }],
    "transform-decorators-legacy",
    "transform-export-extensions",
    "transform-object-rest-spread",
    "lodash"
  ],
  "presets": [
    "es2015",
    ["env", {
      "targets": {
        "node": "current"
      }
    }]
  ]
}
JaKXz commented 7 years ago

I am in the same boat and would have thought that babel-preset-env set to "current" would fix the problem. Not sure why it isn't though. :(

I tried the following .babelrc since I only want to use this plugin in my jest tests:

{
  "presets": [
    "es2015",
    "react"
  ],
  "plugins": [
    "transform-object-rest-spread",
    "react-hot-loader/babel"
  ],
  "env": {
    "test": {
      "plugins": [
        "transform-async-functions",
        "transform-es2015-modules-commonjs",
        "transform-postcss"
      ]
    }
  }
}
wbyoung commented 7 years ago

This just needs to change to be a specific version and we need to update the tested versions.

Would you mind creating a PR and testing with your configuration?

wbyoung commented 7 years ago

Resolved by #38.