-
Notifications
You must be signed in to change notification settings - Fork 147
Optional Chaining support #866
Comments
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 Without esm, optional chaining works fine. |
This is too bad. Same problem with nullish coalescing in Node 14+ |
Update to the latest version of NodeJS to benefit from the latest improvements and features, notably optional chaining and nullish coalescing, for use in the API code without Babel. Use CommonJS in API code as they're more stable than ESM. Get rid of the `esm` package that provided full support for ESM as it doesn't support optional chaining (standard-things/esm#866). Improve export consistency in front. Use the `babel-eslint` ESLint parser as the default ESLint parser doesn't support optional chaining yet (!).
Update to the latest version of NodeJS to benefit from the latest improvements and features, notably optional chaining and nullish coalescing, for use in the API code without Babel. Use CommonJS in API code as they're more stable than ESM. Get rid of the `esm` package that provided full support for ESM as it doesn't support optional chaining (standard-things/esm#866). Improve export consistency in front. Use the `babel-eslint` ESLint parser as the default ESLint parser doesn't support optional chaining yet (!).
Update to the latest version of NodeJS to benefit from the latest improvements and features, notably optional chaining and nullish coalescing, for use in the API code without Babel. Use CommonJS in API code as they're more stable than ESM. Get rid of the `esm` package that provided full support for ESM as it doesn't support optional chaining (standard-things/esm#866). Improve export consistency in front. Use the `babel-eslint` ESLint parser as the default ESLint parser doesn't support optional chaining yet (!).
Update to the latest version of NodeJS to benefit from the latest improvements and features, notably optional chaining and nullish coalescing, for use in the API code without Babel. Use CommonJS in API code as they're more stable than ESM. Get rid of the `esm` package that provided full support for ESM as it doesn't support optional chaining (standard-things/esm#866). Improve export consistency in front. Use the `babel-eslint` ESLint parser as the default ESLint parser doesn't support optional chaining yet (!).
FWIW, until esm may support it, it's working for me to use |
Just stumbled on this issue too. Looking forward for the fix. |
Same issue.
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! 🙌 |
More over, EcmaModules support is available in Node 12 already |
That seems true that with V12+ and especially with V16, you have pretty good support for ECMAScript modules. |
Optional chaining makes the code more concise and easier to reason about. Needs a fork of esm because of standard-things/esm#866. Closes #10278 from domoritz/modern-js Lead-authored-by: Dominik Moritz <[email protected]> Co-authored-by: p42-ai[bot] <72252241+p42-ai[bot]@users.noreply.github.com> Signed-off-by: Sutou Kouhei <[email protected]>
We needed this issue fixed so have forked and published our forked repo if anyone needs it. |
Ah wallaby! @smcenlly. I should revisit this stuff. |
Optional chaining makes the code more concise and easier to reason about. Needs a fork of esm because of standard-things/esm#866. Closes apache#10278 from domoritz/modern-js Lead-authored-by: Dominik Moritz <[email protected]> Co-authored-by: p42-ai[bot] <72252241+p42-ai[bot]@users.noreply.github.com> Signed-off-by: Sutou Kouhei <[email protected]>
`esm` doesn't support it: standard-things/esm#866
`esm` doesn't support it: standard-things/esm#866
esm not optional chaining support, workaround standard-things/esm#866 (comment)
This code fails. Any import word found in the code will make it fail:
|
Thanks for this @smcenlly! Unfortunately I'm still having issues with it. I was using esm to allow mocha to use esm imports, but using I'm running node 14.17. ***EDIT |
Fix in PR a year and a half ago and STILL not merged? |
@toastyghost As others have pointed out, we should consider this project dead until proven differently. |
Yup, native ES modules support was added in Node 12.~20 |
Hi everyone, I had the same problem about optional chaining operator (with node >= 14 ) when I did: In my case, it also fixes nullish coalescing operator ( I hope it could help. |
Note that node now have decent support for modules built-in, there is no real need for a dependency anymore. |
Node's support for built-in modules is still god-awful. You have to jump through all sorts of hoops and define things at the project level to get them to work. I'd really like to have optional chaining support with |
Can you elaborate on this? As far as I know, you only need either setting "type: module" in your package.json or name your files .mjs, both options providing great compatibility with all the tooling around (like bundlers). |
Some tooling doesn't do well with |
I see. I didn't encounter any situation that needed renaming everything; most bundler just accept whatever you throw at them, and not having the full file name is not really on the table either. But I see how some workflow might require that. Still, it is likely that |
with latest node (13.8.0)
works with when running
node --harmony
but doesnot work with esm:
node --harmony -r esm example.js
The text was updated successfully, but these errors were encountered: