with latest node (13.8.0)
// example.js
let a
a?.b
works with when running node --harmony
but doesnot work with esm: node --harmony -r esm example.js
// example.js
import path from 'path'
let a
a?.b
a?.b
^
SyntaxError: Invalid or unexpected token
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1171:10)
Are there any updates on this issue?
Some update on this issue, I tried on the last NodeJS version (14.1.0) because you don't need --harmony flag anymore. But it still not working :disappointed:
Without esm, optional chaining works fine.
This is too bad. Same problem with nullish coalescing in Node 14+
FWIW, until esm may support it, it's working for me to use @babel/register with the plugin @babel/plugin-proposal-optional-chaining (and I also needed the plugin babel-plugin-transform-import-meta for import.meta.url which, unlike esm, babel/register doesn't understand as well as babel-plugin-transform-async-to-promises to avoid regenerator-runtime for async).
Just stumbled on this issue too. Looking forward for the fix.
Same issue.
id: options.params?.id
^
SyntaxError: Invalid or unexpected token
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
The reason I use esm is so that I don't have to build my code using Babel. So using babel plugins isn't an option for me.
Node v14.3.0 with and without --harmony flag
I'll update the parser. Thanks!
@jdalton will this parser update include nullish coalescing? 馃檹
@jdalton Excited for this one!
@jdalton Any update on when we can expect this?
It works after updating acorn.
Awesome! Hope this gets released soon 馃憤
Any ETA on this?
It's fixed in my PR. #883
You can use it or fork it. I'm not a maintainer, so I can't merge/publish.
Can you please update the parser?
@luluhoc there is a PR waiting to merge.
We've been using @jsg2021's PR in production for 4 months now without an issue! 馃檶
Most helpful comment
I'll update the parser. Thanks!