nuxt: Nuxt 3 not working on iOS <= 12
Environment
- Operating System:
Darwin - Node Version:
v14.20.1 - Nuxt Version:
3.2.2 - Nitro Version:
2.2.3 - Package Manager:
pnpm@7.28.0 - Builder:
vite - User Config:
- - Runtime Modules:
- - Build Modules:
-
Reproduction
Created a minimal reproduction on stackblitz, while the problem is, that stackblitz (and codesandbox) does not work on iOS (12). So I hope this is not a problem!
But basically all you need to do is installing Nuxt 3 and open the page with an iOS device on iOS 12 or below.
In the stackblitz example above, I’ve created this simple counter app, to demonstrate, that no interaction works (on iOS <=12):
<template>
<div>
<!-- <NuxtWelcome /> -->
<h1>count: {{ count }}</h1>
<button @click="count++">+</button>
</div>
</template>
<script setup>
const count = ref(0);
</script>
But the same error occurs, when you stay with the default app.vue (<NuxtWelcome />).
Describe the bug
First: I think this is the same bug as described here, but somehow the issue was closed. No, not vite: I’ve tested it, and it has nothing to do with vite as builder, because I’ve tested it also with webpack as builder and you can verify this too by trying it with webpack. And if you have a look at can i use (es6-module, dynamic-import, import.meta), vite is supported on iOS 12.
Here is a video of the app running on an iPad with iOS 12 (via browserstack.com):
https://user-images.githubusercontent.com/2291224/221809915-5077d637-f7e0-45b4-bbc6-e90d473373a9.mp4
As you can see, the problem is that an error is thrown, that stops the app from working (both vite and webpack):
SyntaxError: Unexpected token '?' (program):1
promiseReactionJob @ (program):1
Safari on iOS 12 (from 2018/19) is still a relevant browser with 0.42%, as you can see on usage tables. So I hope we can fix this!
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 1
- Comments: 22 (7 by maintainers)
To clarify, we are talking about
iPhone 5S,iPhone 6/6 PlusandiPod touch (6th generation), i.e. 2015 and older devices (or ones that didn’t update).It can make sense to precisely track the library/feature that is causing the failure, although it must be noted that we are talking about 8-years-ago internet, and it might not be worth changing them.
P.s. Note also that Vue 3 requires ES2015, i.e. iOS 10.x+
Alright. Now I’ve got your point.
Well, I don’t think that we can expect our website users to update their devices to a version, on which Nuxt 3 runs …
Hi, I resolved an issue using the following approach. You may check an example of my
nuxt.config.So, you may add as many polyfills as required by your concrete case. In dev tools (console) you will see errors. Most likely, they could be solved by polyfills.
Pay attention, that your polyfill must be loaded before nuxt/vue application is bootstrapped. Also, it should be run on browser (not on your server)
Good luck 😃
I’m using this in my nuxt.config.js
The default value of vite.build.target is safari14 which require atleast iOS 14, change it to safari12 makes my app able to run on iOS 12.
@vitejs/plugin-legacy also works (#20087) but it will increase the javascript file size by atleast 1MB and it will introduce
System is not definederror (https://github.com/vitejs/vite/discussions/6581).I really do not know where you found this information, but it simply is not true. iOS 12 (as mentioned above) was released in September 2018 and of course, it is still relevant.