Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional chaining doesn't work #137

Closed
neurocmd opened this issue Sep 28, 2020 · 4 comments
Closed

Optional chaining doesn't work #137

neurocmd opened this issue Sep 28, 2020 · 4 comments

Comments

@neurocmd
Copy link

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?

@Conduitry
Copy link
Member

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.

@rabidpug
Copy link

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.

@fsevenm
Copy link

fsevenm commented Oct 11, 2020

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)

@N-NeelPatel
Copy link

Facing this problem while using optional chaining and coalescing operator in storybook svelte.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants