Home > front end >  Svelte app fails on mobile browsers due to optional chaining SyntaxError
Svelte app fails on mobile browsers due to optional chaining SyntaxError

Time:06-07

I'm working on a simple Svelte app, using Vite as a build tool, which works fine on my desktop browsers (Chrome/Edge alike), but when trying to browse the dev build (pnpm dev --host) on a mobile device (either an Android simulator or my iPhone) it doesn't work:

enter image description here

It looks like the ES support is different, or Vite doesn't transpile this code further to a compatible version for those browsers. The same ?.nickname expression works fine in desktop. I also tried changing target to ES2015 in tsconfig.json but the .svelte file in the browser doesn't change... Any ideas?

CodePudding user response:

You can find support for ?. or enter image description here

  • Related