Optional chaining doesn't work
neurocmd opened this issue · 4 comments
Optional chaining doesn't work with webpack and it most likely related to svelte-loader, as it works with rollup. Svelte itself already supports optional chaining since acorn has shipped it (see repl). But in webpack I am getting the next error:
Will the issue be fixed?
We'd need a repro for this. My guess is that you're either accidentally using an older version of Svelte or this is an error from a different plugin/loader that doesn't support this syntax.
Webpack 4 doesn’t support optional chaining as it uses an old version of acorn, see webpack/webpack#10227 (comment)
Will be fixed in Webpack 5.
If you're using Svelte + Webpack 4 and want to use nullish coaslescing operator or optional chaining, you can use resolutions for now, I guess.
Just add it to your top level package.json file,
"resolutions": {
"acorn": "8.0.1"
},Then, run yarn install.
I've tested using null coalescing operator, no more errors, but I've not tested optional chaining yet.
See this issue for further information, there's also npm way,
webpack/webpack#10227 (comment)

