Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Occurrence of optional chaining operator not getting replaced #1423

Closed
mcmxcdev opened this issue Aug 21, 2020 · 4 comments
Closed

Occurrence of optional chaining operator not getting replaced #1423

mcmxcdev opened this issue Aug 21, 2020 · 4 comments

Comments

@mcmxcdev
Copy link

mcmxcdev commented Aug 21, 2020

Describe the bug
Not sure if this is a thing, but I tried deploying to Netlify and the build failed due to Unexpected token "." in __sapper__/build/server/server.js.

It turned out that this piece of code ended up in the legacy bundle untranspiled:

  <meta
    name="description"
    content="{segment ? post?.excerpt : 'Opinions and viewpoints about Programming, Lifestyle and other topics.'}"
  />

While the optional chaining operator wasn't replaced in this snippet, a couple lines above it was replaced just fine, but there it was used in variable assignments.

To Reproduce

Use code snippet above and run "export": "NODE_ENV=production sapper export --legacy"

Expected behavior
Optional chaining operator gets transpiled.

Information about your Sapper Installation:

  • Your browser: Brave Browser: 1.12.114

  • Your hosting environment: Local

  • If it is an exported (npm run export) or dynamic application: exported application

Severity
How severe an issue is this bug to you? Is this annoying, blocking some users, blocking an upgrade or blocking your usage of Sapper entirely?

Used post && post.excerpt instead, so neglectable

@benmccann
Copy link
Member

benmccann commented Aug 21, 2020

Svelte recently added support for this sveltejs/svelte#1972

It's not yet supported in rollup-plugin-terser though TrySound/rollup-plugin-terser#85

Closing this since it's not an issue in Sapper, but in an external library

@benmccann
Copy link
Member

Oh, actually this request looks more like a question about how to setup your babel config for the legacy build to support this. I see someone did that in sveltejs/svelte#1972 (comment) which might be helpful to you

@TrySound
Copy link

@mcmxcdev
Copy link
Author

mcmxcdev commented Aug 21, 2020

What I actually meant was that just two lines above the error in my code (not visible in the snippet, sorry), the optional chaining operator was indeed replaced correctly, when it was used in a variable assignment.

The untranspiled one is the one in the example above, when used inside ternary expression.

But I guess rollup-plugin-terser is my best bet then ;)

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

No branches or pull requests

3 participants