Jotai incompatibility issue with Expo 53+ / React Native 0.79+ #3041
Replies: 5 comments 28 replies
-
FWIW: Because this will be an issue with more packages in the React Native community, there will be a 2nd workaround: expo/expo#36074 |
Beta Was this translation helpful? Give feedback.
-
Hi @byCedric ! pmndrs/zustand#1967 is a related discussion. I do think Having that said, I think the situation hasn't changed for a very long time, so I think I can consider adding |
Beta Was this translation helpful? Give feedback.
-
import.meta issue on RN should be fixed from https://github.com/pmndrs/jotai/releases/tag/v2.12.4 |
Beta Was this translation helpful? Give feedback.
-
The v2.12.4 did not fix it for me. Am I the only one still having issues with the latest patch? cc @ochanje210 |
Beta Was this translation helpful? Give feedback.
-
See also: pmndrs/zustand#1967 (reply in thread) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Bug Description
I noticed Jotai is a dual-published package with both CJS and ESM code. But, the ESM contains Vite-specific code, like
import.meta.env.MODE
.React Native 0.79 uses Metro 0.82.x which enables
package.json:exports
by default, meaning that if you use these imports, Metro now would resolve the following:require('jotai')
-> CJS version of Jotaiimport { .. } from 'jotai'
-> ESM version of Jotaiawait import('jotai')
-> ESM version of JotaiCombine this with the Vite-only features in the ESM builds, Jotai will break Metro with the following error:
Ideally, Jotai should just work out of the box with React Native. One way could be adding a
react-native
specific resolution topackage.json:exports
- pointing to the CJS code - which should be picked up by Metro.The other way is a little bit harder, but definitely something that should be on the table. Adding support to Vite-specific code patterns in Metro, through an RFC.
Already using Expo 53+ and need a workaround?
We can tell Metro to resolve
jotai(/*)
differently, withoutpackage.json:exports
support. Configuring metro.config.js for Expo with this should help:Reproduction Link
https://github.com/byCedric/jotai-expo-53-issue
npm run start
Beta Was this translation helpful? Give feedback.
All reactions