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

Platform select on web falls back native when bundling with metro #27801

Closed
jparksecurity opened this issue Mar 21, 2024 · 4 comments
Closed
Assignees
Labels
CLI Versioned Expo CLI -- `npx expo start` Issue accepted

Comments

@jparksecurity
Copy link

jparksecurity commented Mar 21, 2024

Summary

Ref: https://discord.com/channels/695411232856997968/1219438969763401878/1219438969763401878

what the expected behavior is

Platform.select falls back to default, which does on expo start --web, when web is not specified.

what is actually happening

Platform.select falls back to native when bundling with metro by expo export --platform web.

What platform(s) does this occur on?

Web

SDK Version

50

Environment

  expo-env-info 1.2.0 environment info:
   System:
     OS: macOS 14.4
     Shell: 5.9 - /bin/zsh
   Binaries:
     Node: 20.11.1 - ~/.nvm/versions/node/v20.11.1/bin/node
     Yarn: 4.0.1 - ~/.nvm/versions/node/v20.11.1/bin/yarn
     npm: 10.2.4 - ~/.nvm/versions/node/v20.11.1/bin/npm
   SDKs:
     iOS SDK:
       Platforms: DriverKit 23.2, iOS 17.2, macOS 14.2, tvOS 17.2, watchOS 10.2
   IDEs:
     Android Studio: 2023.1 AI-231.9392.1.2311.11330709
     Xcode: 15.1/15C65 - /usr/bin/xcodebuild
   npmPackages:
     babel-preset-expo: ^10.0.0 => 10.0.1 
     expo: ~50.0.11 => 50.0.11 
     react: 18.2.0 => 18.2.0 
     react-dom: 18.2.0 => 18.2.0 
     react-native: 0.73.4 => 0.73.4 
     react-native-web: ^0.19.10 => 0.19.10 
   Expo Workflow: managed

Minimal reproducible example

https://github.com/jparksecurity/platform-select

Run yarn web to check if Platform.select falls back to default.

Then, run yarn expo export --platform web.

  1. Check the app entry js under dist/_expo/static/js/web and search Open up App.js to start working on your app!. You will see native next to this text.
  2. Or serve it locally(npx serve dist --single) to check in a browser.
@jparksecurity jparksecurity added CLI Versioned Expo CLI -- `npx expo start` needs validation Issue needs to be validated labels Mar 21, 2024
@expo-bot expo-bot removed the needs validation Issue needs to be validated label Mar 21, 2024
@jparksecurity
Copy link
Author

@keith-kurak FYI

@byCedric byCedric self-assigned this Mar 29, 2024
@expo-bot
Copy link
Collaborator

Thank you for filing this issue!
This comment acknowledges we believe this may be a bug and there’s enough information to investigate it.
However, we can’t promise any sort of timeline for resolution. We prioritize issues based on severity, breadth of impact, and alignment with our roadmap. If you’d like to help move it more quickly, you can continue to investigate it more deeply and/or you can open a pull request that fixes the cause.

@byCedric
Copy link
Member

byCedric commented Mar 29, 2024

Hi @jparksecurity! Thanks for creating this issue. Unfortunately, this is a bug inside Metro itself. To give you a quick summary:

Since this is quite a big change, I'm not sure if we can backport this to SDK 50, but I'll check.

To avoid this issue, you could add the Platform.select({ web: 'web' }) property, or use Platform.OS === 'web', which should work fine for SDK 50 right now.

Hope this helps!

@jparksecurity
Copy link
Author

@byCedric Thank you for the detailed explanation! Sorry, I didn't realize the fix had been merged. I'll keep an eye out for the fix release!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLI Versioned Expo CLI -- `npx expo start` Issue accepted
Projects
None yet
Development

No branches or pull requests

3 participants