relay-tools / react-relay-network-layer

ReactRelayNetworkLayer with middlewares and query batching for Relay Classic.
MIT License
277 stars 47 forks source link

error: Processing of node_modules/react-relay-network-layer/lib/middleware/gqErrors.js failed. SyntaxError: Unexpected token (80:376) #45

Closed felix-d closed 7 years ago

felix-d commented 7 years ago

I'm using Brunch and this function makes compilation fail

function noticeAbsentStack() {
  return '\n    If you using \'express-graphql\', you may get server stack-trace for error.\n    Just tune \'formatError\' to return \'stack\' with stack-trace:\n\n    import graphqlHTTP from \'express-graphql\';\n\n    const graphQLMiddleware = graphqlHTTP({\n      schema: myGraphQLSchema,\n      formatError: (error) => ({\n        message: error.message,\n        stack: process.env.NODE_ENV === \'development\' ? error.stack.split(\'\\n\') : null,\n      })\n    });\n\n    app.use(\'/graphql\', graphQLMiddleware);';
}
18:12:20 - error: Processing of node_modules/react-relay-network-layer/lib/middleware/gqErrors.js failed. SyntaxError: Unexpected token (80:376)
  at Parser.pp$4.raise (/Users/felixdescoteaux/Projects/expenses/node_modules/acorn/dist/acorn.js:2488:13)
  at Parser.pp.unexpected (/Users/felixdescoteaux/Projects/expenses/node_modules/acorn/dist/acorn.js:623:8)
  at Parser.pp.semicolon (/Users/felixdescoteaux/Projects/expenses/node_modules/acorn/dist/acorn.js:600:59)
  at Parser.pp$1.parseReturnStatement (/Users/felixdescoteaux/Projects/expenses/node_modules/acorn/dist/acorn.js:894:55)
  at Parser.pp$1.parseStatement (/Users/felixdescoteaux/Projects/expenses/node_modules/acorn/dist/acorn.js:744:32)
  at Parser.pp$1.parseBlock (/Users/felixdescoteaux/Projects/expenses/node_modules/acorn/dist/acorn.js:1040:23)
  at Parser.pp$3.parseFunctionBody (/Users/felixdescoteaux/Projects/expenses/node_modules/acorn/dist/acorn.js:2362:22)
  at Parser.pp$1.parseFunction (/Users/felixdescoteaux/Projects/expenses/node_modules/acorn/dist/acorn.js:1132:8)
  at Parser.pp$1.parseFunctionStatement (/Users/felixdescoteaux/Projects/expenses/node_modules/acorn/dist/acorn.js:868:15)
  at Parser.pp$1.parseStatement (/Users/felixdescoteaux/Projects/expenses/node_modules/acorn/dist/acorn.js:739:17)
  at Parser.pp$1.parseBlock (/Users/felixdescoteaux/Projects/expenses/node_modules/acorn/dist/acorn.js:1040:23)
  at Parser.pp$3.parseFunctionBody (/Users/felixdescoteaux/Projects/expenses/node_modules/acorn/dist/acorn.js:2362:22)
  at Parser.pp$1.parseFunction (/Users/felixdescoteaux/Projects/expenses/node_modules/acorn/dist/acorn.js:1132:8)
  at Parser.pp$3.parseExprAtom (/Users/felixdescoteaux/Projects/expenses/node_modules/acorn/dist/acorn.js:1999:17)
  at Parser.pp$3.parseExprSubscripts (/Users/felixdescoteaux/Projects/expenses/node_modules/acorn/dist/acorn.js:1872:19)
  at Parser.pp$3.parseMaybeUnary (/Users/felixdescoteaux/Projects/expenses/node_modules/acorn/dist/acorn.js:1849:17)
  at Parser.pp$3.parseExprOps (/Users/felixdescoteaux/Projects/expenses/node_modules/acorn/dist/acorn.js:1791:19)
  at Parser.pp$3.parseMaybeConditional (/Users/felixdescoteaux/Projects/expenses/node_modules/acorn/dist/acorn.js:1774:19)
  at Parser.pp$3.parseMaybeAssign (/Users/felixdescoteaux/Projects/expenses/node_modules/acorn/dist/acorn.js:1750:19)
  at Parser.pp$3.parseParenAndDistinguishExpression (/Users/felixdescoteaux/Projects/expenses/node_modules/acorn/dist/acorn.js:2056:30)
  at Parser.pp$3.parseExprAtom (/Users/felixdescoteaux/Projects/expenses/node_modules/acorn/dist/acorn.js:1978:41)
  at Parser.pp$3.parseExprSubscripts (/Users/felixdescoteaux/Projects/expenses/node_modules/acorn/dist/acorn.js:1872:19)
  at Parser.pp$3.parseMaybeUnary (/Users/felixdescoteaux/Projects/expenses/node_modules/acorn/dist/acorn.js:1849:17)
  at Parser.pp$3.parseExprOps (/Users/felixdescoteaux/Projects/expenses/node_modules/acorn/dist/acorn.js:1791:19)
  at Parser.pp$3.parseMaybeConditional (/Users/felixdescoteaux/Projects/expenses/node_modules/acorn/dist/acorn.js:1774:19)
  at Parser.pp$3.parseMaybeAssign (/Users/felixdescoteaux/Projects/expenses/node_modules/acorn/dist/acorn.js:1750:19)
  at Parser.pp$3.parseExpression (/Users/felixdescoteaux/Projects/expenses/node_modules/acorn/dist/acorn.js:1722:19)
  at Parser.pp$1.parseStatement (/Users/felixdescoteaux/Projects/expenses/node_modules/acorn/dist/acorn.js:777:45)
  at Parser.pp$1.parseBlock (/Users/felixdescoteaux/Projects/expenses/node_modules/acorn/dist/acorn.js:1040:23)
  at Parser.pp$3.parseFunctionBody (/Users/felixdescoteaux/Projects/expenses/node_modules/acorn/dist/acorn.js:2362:22)
  at Parser.pp$1.parseFunction (/Users/felixdescoteaux/Projects/expenses/node_modules/acorn/dist/acorn.js:1132:8)
  at Parser.pp$3.parseExprAtom (/Users/felixdescoteaux/Projects/expenses/node_modules/acorn/dist/acorn.js:1999:17)
  at Parser.pp$3.parseExprSubscripts (/Users/felixdescoteaux/Projects/expenses/node_modules/acorn/dist/acorn.js:1872:19)
  at Parser.pp$3.parseMaybeUnary (/Users/felixdescoteaux/Projects/expenses/node_modules/acorn/dist/acorn.js:1849:17)
  at Parser.pp$3.parseExprOps (/Users/felixdescoteaux/Projects/expenses/node_modules/acorn/dist/acorn.js:1791:19)
  at Parser.pp$3.parseMaybeConditional (/Users/felixdescoteaux/Projects/expenses/node_modules/acorn/dist/acorn.js:1774:19)
  at Parser.pp$3.parseMaybeAssign (/Users/felixdescoteaux/Projects/expenses/node_modules/acorn/dist/acorn.js:1750:19)
  at Parser.pp$3.parseExprList (/Users/felixdescoteaux/Projects/expenses/node_modules/acorn/dist/acorn.js:2418:20)
  at Parser.pp$3.parseSubscripts (/Users/felixdescoteaux/Projects/expenses/node_modules/acorn/dist/acorn.js:1900:29)
  at Parser.pp$3.parseExprSubscripts (/Users/felixdescoteaux/Projects/expenses/node_modules/acorn/dist/acorn.js:1875:21)
  at Parser.pp$3.parseMaybeUnary (/Users/felixdescoteaux/Projects/expenses/node_modules/acorn/dist/acorn.js:1849:17)
  at Parser.pp$3.parseExprOps (/Users/felixdescoteaux/Projects/expenses/node_modules/acorn/dist/acorn.js:1791:19)
  at Parser.pp$3.parseMaybeConditional (/Users/felixdescoteaux/Projects/expenses/node_modules/acorn/dist/acorn.js:1774:19)
  at Parser.pp$3.parseMaybeAssign (/Users/felixdescoteaux/Projects/expenses/node_modules/acorn/dist/acorn.js:1750:19)
  at Parser.pp$3.parseExpression (/Users/felixdescoteaux/Projects/expenses/node_modules/acorn/dist/acorn.js:1722:19)
  at Parser.pp$1.parseStatement (/Users/felixdescoteaux/Projects/expenses/node_modules/acorn/dist/acorn.js:777:45)
  at Parser.pp$1.parseTopLevel (/Users/felixdescoteaux/Projects/expenses/node_modules/acorn/dist/acorn.js:672:23)
  at Parser.parse (/Users/felixdescoteaux/Projects/expenses/node_modules/acorn/dist/acorn.js:529:15)
  at Object.parse (/Users/felixdescoteaux/Projects/expenses/node_modules/acorn/dist/acorn.js:3378:37)
  at parse (/Users/felixdescoteaux/Projects/expenses/node_modules/detective/index.js:9:18)
  at Function.exports.find (/Users/felixdescoteaux/Projects/expenses/node_modules/detective/index.js:44:15)
  at module.exports (/Users/felixdescoteaux/Projects/expenses/node_modules/detective/index.js:23:20)
  at /Users/felixdescoteaux/Projects/expenses/node_modules/deppack/lib/explore.js:61:43
  at sourceFile (/Users/felixdescoteaux/Projects/expenses/node_modules/deppack/lib/explore.js:104:18)

I don't know why... it seems super odd to me, this string seems legit and it was added 1 year ago. When copy pasting this function in the console, everything works fine

When I replace the string by an empty string my app compiles without any problem.

wtf? thanks! 😄

felix-d commented 7 years ago

oddly enough, it worked when I moved the folder out of node modules and imported the lib from there 🤔

nodkz commented 7 years ago

Really very strange. I'm using react-relay-network-layer v2.0.1 and my file gqErrors.js ends with 77 line. So line 80 does not exist.

It seems that problem in your bundler Brunch. I'm using Webpack and it makes vendor bundle for me without compile errors.

I'm close this issue for now cause I don't know what to do. If you'll find the root of problem please drop a line with a solution for further googlers.

Thanks.

felix-d commented 7 years ago

Thanks @nodkz, this is what I suspect as well, opened an issue in the brunch repo 👍