Skip to content
This repository has been archived by the owner on Apr 9, 2020. It is now read-only.

[babel 6] SyntaxError: Unexpected token: async () => { #60

Closed
BerndWessels opened this issue Dec 13, 2015 · 1 comment
Closed

[babel 6] SyntaxError: Unexpected token: async () => { #60

BerndWessels opened this issue Dec 13, 2015 · 1 comment

Comments

@BerndWessels
Copy link

Hello

I am testing the new babel 6 support with "babel-plugin-react-transform": "^2.0.0-beta1" but get a syntax error, see below.

Is this a babel 6 issue or related to this plugin?

> babel-node --eval "require('./scripts/externalsUpdate')().catch(err => console.error(err.stack))"

/usr/local/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/index.js:547
      throw err;
      ^

SyntaxError: /Users/bernd/WebstormProjects/react-webpack/scripts/externalsUpdate.js: Unexpected token (20:49)
  18 | 
  19 | // Save JSON of full schema introspection for Babel Relay Plugin to use
> 20 | export default task('update externals', async () => {
     |                                                  ^
  21 | 
  22 |   // react
  23 |   console.log('copying react v' + react.version);
    at Parser.pp.raise (/usr/local/lib/node_modules/babel-cli/node_modules/babylon/lib/parser/location.js:22:13)
    at Parser.pp.unexpected (/usr/local/lib/node_modules/babel-cli/node_modules/babylon/lib/parser/util.js:91:8)
    at Parser.pp.parseAsyncArrowFromCallExpression (/usr/local/lib/node_modules/babel-cli/node_modules/babylon/lib/parser/expression.js:357:47)
    at Parser.<anonymous> (/usr/local/lib/node_modules/babel-cli/node_modules/babylon/lib/plugins/flow.js:972:20)
    at Parser.parseAsyncArrowFromCallExpression (/usr/local/lib/node_modules/babel-cli/node_modules/babylon/lib/plugins/flow.js:972:20)
    at Parser.pp.parseSubscripts (/usr/local/lib/node_modules/babel-cli/node_modules/babylon/lib/parser/expression.js:308:21)
    at Parser.pp.parseExprSubscripts (/usr/local/lib/node_modules/babel-cli/node_modules/babylon/lib/parser/expression.js:275:15)
    at Parser.pp.parseMaybeUnary (/usr/local/lib/node_modules/babel-cli/node_modules/babylon/lib/parser/expression.js:245:19)
    at Parser.pp.parseExprOps (/usr/local/lib/node_modules/babel-cli/node_modules/babylon/lib/parser/expression.js:176:19)
    at Parser.pp.parseMaybeConditional (/usr/local/lib/node_modules/babel-cli/node_modules/babylon/lib/parser/expression.js:158:19)

This is my .babelrc

{
  "presets": ["react", "es2015"],
  "env": {
    "development": {
      "plugins": [
        [
          "babel-relay-plugin-loader",
          "react-transform", {
            "transforms": [{
              "transform": "react-transform-hmr",
              "imports": ["react"],
              "locals": ["module"]
            }, {
              "transform": "react-transform-catch-errors",
              "imports": ["react", "redbox-react"]
            }]
        }]
      ]
    },
    "production": {
      "plugins": [
        [
          "babel-relay-plugin-loader"
        ]
      ]
    }
  }
}

And these are my dependencies - all up to the latest within their semver rule:

"dependencies": {
  "bootstrap": "^3.0.0",
  "history": "^1.0.0",
  "lodash": "^3.0.0",
  "mysql": "^2.0.0",
  "react": "^0.14.0",
  "react-bootstrap": "^0.28.0",
  "react-dom": "^0.14.0",
  "react-relay": "^0.6.0",
  "react-router": "^1.0.0",
  "react-router-relay": "^0.8.0",
  "sequelize": "^3.0.0"
},
"devDependencies": {
  "autoprefixer": "^6.0.0",
  "babel-core": "^6.0.0",
  "babel-eslint": "^5.0.0-beta4",
  "babel-loader": "^6.0.0",
  "babel-plugin-react-transform": "^2.0.0-beta1",
  "babel-preset-es2015": "^6.0.0",
  "babel-preset-react": "^6.0.0",
  "babel-relay-plugin": "^0.6.0",
  "babel-relay-plugin-loader": "^0.6.0",
  "browser-sync": "^2.0.0",
  "browser-sync-webpack-plugin": "^1.0.0",
  "clean-webpack-plugin": "^0.1.0",
  "copy-webpack-plugin": "^0.3.0",
  "cors": "^2.0.0",
  "css-loader": "^0.23.0",
  "express": "^4.0.0",
  "express-graphql": "^0.4.0",
  "extract-text-webpack-plugin": "^0.9.0",
  "faker": "^3.0.0",
  "file-loader": "^0.8.0",
  "graphiql": "^0.4.0",
  "graphql": "^0.4.0",
  "graphql-relay": "^0.3.0",
  "history": "^1.0.0",
  "html-webpack-plugin": "^1.0.0",
  "isparta-instrumenter-loader": "^1.0.0",
  "jasmine-core": "^2.0.0",
  "karma": "^0.13.0",
  "karma-chrome-launcher": "^0.2.0",
  "karma-coverage": "^0.5.0",
  "karma-jasmine": "^0.3.0",
  "karma-phantomjs-launcher": "^0.2.0",
  "karma-sourcemap-loader": "^0.3.0",
  "karma-spec-reporter": "^0.0.23",
  "karma-webpack": "^1.0.0",
  "less": "^2.0.0",
  "less-loader": "^2.0.0",
  "node-libs-browser": "^0.5.0",
  "null-loader": "^0.1.0",
  "phantomjs": "^1.0.0",
  "postcss-loader": "^0.8.0",
  "q": "^1.0.0",
  "raw-loader": "^0.5.0",
  "react-transform-catch-errors": "^1.0.0",
  "react-transform-hmr": "^1.0.0",
  "redbox-react": "^1.0.0",
  "relay-local-schema": "^0.3.0",
  "style-loader": "^0.13.0",
  "webpack": "^1.0.0",
  "webpack-dev-server": "^1.0.0"
}
@jamiebuilds
Copy link
Collaborator

This has nothing to do with this plugin, but you're missing the plugin/preset for async functions. Async functions are not part of es2015.

Please take your general Babel questions to https://slack.babeljs.io or https://discuss.babeljs.io in the future.

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

2 participants