esxjs / esx

Like JSX, but native and fast
MIT License
652 stars 11 forks source link

optional chaining and rest spread? #17

Open j-5-s opened 4 years ago

j-5-s commented 4 years ago

Hi, my babel transpiling seems to be breaking with other things like optionals and rest spread plugins are used.I've put this esx-ssr at the end of the plugins array but i think maybe the acorn parser in to-esx doesnt read the transpiled code as all plugins are run in parellel maybe? Are you aware of any issues using this with other plugins like babel/plugin-proposal-optional-chaining?

Error:

Webpack Build Time For Server Build:  885 ms
(node:36582) UnhandledPromiseRejectionWarning: Error: Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError: <REMOVED>/src/server.js: Unexpected token (36:33)
    at Object.pp$4.raise (<REMOVED>node_modules/acorn/dist/acorn.js:2825:15)
    at Object.pp.unexpected (<REMOVED>node_modules/acorn/dist/acorn.js:689:10)
    at Object.pp$3.parseExprAtom (<REMOVED>/node_modules/acorn/dist/acorn.js:2270:12)
    at Object.parseExprAtom (<REMOVED>/node_modules/acorn-jsx/index.js:445:22)
    at Object.pp$3.parseExprSubscripts (<REMOVED>/node_modules/acorn/dist/acorn.js:2089:21)
    at Object.pp$3.parseMaybeUnary (<REMOVED>/node_modules/acorn/dist/acorn.js:2066:19)
    at Object.pp$3.parseExprOps (<REMOVED>/node_modules/acorn/dist/acorn.js:2010:21)
    at Object.pp$3.parseMaybeConditional (<REMOVED>/node_modules/acorn/dist/acorn.js:1993:21)
    at Object.pp$3.parseMaybeAssign (<REMOVED>/node_modules/acorn/dist/acorn.js:1968:21)
    at Object.pp$3.parseMaybeConditional (<REMOVED>/node_modules/acorn/dist/acorn.js:1998:30)
    at Object.pp$3.parseMaybeAssign (<REMOVED>/node_modules/acorn/dist/acorn.js:1968:21)
    at Object.pp$1.parseVar (<REMOVED>/node_modules/acorn/dist/acorn.js:1228:26)
    at Object.pp$1.parseVarStatement (<REMOVED>/node_modules/acorn/dist/acorn.js:1092:10)
    at Object.pp$1.parseStatement (<REMOVED>/node_modules/acorn/dist/acorn.js:842:19)
    at Object.pp$1.parseBlock (<REMOVED>/node_modules/acorn/dist/acorn.js:1161:23)
    at Object.pp$3.parseFunctionBody (<REMOVED>/node_modules/acorn/dist/acorn.js:2671:24)

fails on this line

Screen Shot 2020-08-12 at 4 06 36 PM

babel config

Screen Shot 2020-08-12 at 4 02 58 PM
prograhammer commented 4 years ago

I'm experiencing this problem too. I created a babel repl, where I used the exact example the readme in babel-plugin-esx-ssr. But added a line with optional chaining and you can see it breaks. If that line is removed, it works correctly.

https://babeljs.io/en/repl#?browsers=&build=&builtIns=false&spec=false&loose=false&code_lz=JYWwDg9gTgLgBAJQKYEMDG8BmUIjgcilQ3wChS0IA7AZ3gBMUYU4BeOAbzgDcUAbAK5IAXAQAWwAgF9ylWvBhI6bOGj4oaNKihBIA_ADpG3JAbFIiAblnVlAYVyQqSKvHYAKDr0FIpASjYAPjh3Ujg4AB56YG5AsPDIsGCaXCRVakVXSIB6JPjwiKS4FN1ObyEpHLyC7OjY0j8beTgAQTAwFXcA1mCIh3BqF3gOA1HGZilsuNIkAA9IWDh6JEwUAT54NrAgA&debug=false&forceAllTransforms=false&shippedProposals=false&circleciRepo=&evaluate=false&fileSize=false&timeTravel=false&sourceType=module&lineWrap=true&presets=react&prettier=false&targets=&version=7.11.1&externalPlugins=%40babel%2Fplugin-proposal-optional-chaining%407.11.0%2Cbabel-plugin-esx-ssr%401.0.0

image

image image