Closed erikdung closed 7 years ago
Yes, you can use them both (that's why they're plugins in the first place). But it doesn't require anything special on acorn-jsx side.
Also, async/await are natively supported by Acorn without any plugins now, so you just need to set ecmaVersion correctly.
I have the script:
export function configure(trackpoint, feeds, auth, platform) {
return async function (dispatch) {
try {
const response = await put("/api/feed-checker/shop-config", {
trackpoint,
feeds,
platform,
auth: auth && auth.password && auth.username ? auth : null
})
if (response.body.status === 'ok') {
dispatch(configureSuccess())
success('Konfigurace byla úspěšně uložena.')
}
else {
const errors = response.body.errors.reduce((sum, error) => {
sum[feedMapping[error[0]]] = error[1]
return sum
}, {})
dispatch(stopAsyncValidation(platform === 'shoptet' ? 'feedForm' : 'feedForm2', errors))
}
} catch (error) {
console.log(error)
dispatch(configureError(error))
}
}
}
I got the error:
SyntaxError: Unexpected token
i point to line start with async
.
I also tried set ecmaVersion: 7
without success.
Oh right, sorry - you confused me with acorn-es7-plugin
. async/await is in fact ES2017 (ES8), so you need to set ecmaVersion
to either 2017
or 8
.
I have tried both, 2017
& 8
, but the same SyntaxError appeared.
Certainly doesn't fail here: http://astexplorer.net/#/gist/899c54bf6d2f2d0cf6f02d0d5098338e/e408ffcd33b233e2f7f3ff50f99bf8612bcbbc4d
Make sure you're using latest version of Acorn or something.
Hi, is it possible to add acorn-es7-plugin to parse async/await function? Thanks