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

White screen when running on IOS12 #362

Closed
7 tasks done
MrQinYQ opened this issue Sep 2, 2024 · 4 comments
Closed
7 tasks done

White screen when running on IOS12 #362

MrQinYQ opened this issue Sep 2, 2024 · 4 comments

Comments

@MrQinYQ
Copy link

MrQinYQ commented Sep 2, 2024

Describe the bug

error massage:
SyntaxError: Unexpected token '?'

builded file
image

react sourcefile
image

vite config

import { 
  defineConfig, 
} from 'vite'
import react from '@vitejs/plugin-react'


// https://vitejs.dev/config/
export default defineConfig({
  build: {
    sourcemap: true,
  },
  plugins: [
    react({
      babel: {
        browserslistConfigFile: true,
        browserslistEnv: 'production'
      }
    }), 
  ],
})

.browserslistrc

[production]
> 0.5%
last 2 versions
not dead
safari >= 11

[development]
last 1 chrome version
last 1 firefox version

Reproduction

https://github.com/MrQinYQ/vite-test.git

Steps to reproduce

No response

System Info

System:
    OS: macOS 14.4.1
    CPU: (12) arm64 Apple M2 Pro
    Memory: 80.23 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.2.0 - ~/.asdf/installs/nodejs/20.2.0/bin/node
    Yarn: 1.22.19 - ~/.asdf/installs/nodejs/20.2.0/bin/yarn
    npm: 9.6.6 - ~/.asdf/plugins/nodejs/shims/npm
    pnpm: 7.33.6 - ~/.asdf/installs/nodejs/20.2.0/bin/pnpm
  Browsers:
    Chrome: 128.0.6613.86
    Safari: 17.4.1
  npmPackages:
    @vitejs/plugin-legacy: ^5.4.2 => 5.4.2 
    @vitejs/plugin-react: ^4.3.1 => 4.3.1 
    @vitejs/plugin-react-swc: ^3.5.0 => 3.7.0 
    vite: ^5.4.2 => 5.4.2

Used Package Manager

pnpm

Logs

No response

Validations

@ArnaudBarre
Copy link
Member

Babel doesn't run on node_modules in the React plugin, the correct way to support legacy browser is to use https://github.com/vitejs/vite/tree/main/packages/plugin-legacy

@MrQinYQ
Copy link
Author

MrQinYQ commented Sep 2, 2024

Babel doesn't run on node_modules in the React plugin, the correct way to support legacy browser is to use https://github.com/vitejs/vite/tree/main/packages/plugin-legacy

If I know that I don't need to be compatible with browsers that don't support esmodule, but I need to be compatible with iOS 12, do I still need to introduce the legacy plugin? Is this reasonable?

@MrQinYQ
Copy link
Author

MrQinYQ commented Sep 2, 2024

I see, I should use: build.target

@ArnaudBarre
Copy link
Member

Ah yeah if iOS 12 support almost everything except a few new syntax like ?? build.target should do it

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

2 participants