I'm a big user of @svelte.dev for all my web projects. But today I realized that it's really difficult (or impossible) to get sites working on older browsers (eg. iOS 12's Safari) through polyfills, etc.
Comments
Log in with your Bluesky account to leave a comment
I'm getting syntax errors from the browser console. Something about unexpected token. The same site works on other browsers. Actually don't know what the polyfill is missing.
But does make me think, can I use something like babel to transpile the output?
If it's something about an unexpected token, the newish syntax features I can think of that Svelte uses are nullish coalescence and optional chaining. You could try finding a polyfill for that (probably using Babel or sth similar)
But more context is definitely needed here to be sure.
Thanks for the advice! I put my iOS Safari in development mode to look at the error, but it's somewhere in the compiled JS which makes it hard to figure out why it's complaining.
Maybe try adding "safari>=12" to your targets in your vite-legacy config? (According to MDN, Safari 13.1 added support)
I'm not entirely sure what sort of polyfills vite-legacy does though; if it just adds runtime polyfills then it won't work and you'd have to add something else (eg Babel or SWC)
Comments
Afaik Svelte 5 works as low as Safari 10 released in 2016 (due to the proxy requirement).
But does make me think, can I use something like babel to transpile the output?
Are you using Vite?
But more context is definitely needed here to be sure.
This is using vite-legacy to do the polyfills.
I'm not entirely sure what sort of polyfills vite-legacy does though; if it just adds runtime polyfills then it won't work and you'd have to add something else (eg Babel or SWC)