Jotai incompatibility issue with Expo 53+ / React Native 0.79+ #3041
Replies: 10 comments 35 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 |
|
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 |
|
import.meta issue on RN should be fixed from https://github.com/pmndrs/jotai/releases/tag/v2.12.4 |
|
The v2.12.4 did not fix it for me. Am I the only one still having issues with the latest patch? cc @ochanje210 |
|
See also: pmndrs/zustand#1967 (reply in thread) |
|
Hi everyone, I had this issue because I was using Daily.co in my React Native Web project, which depended on jotai, and everything worked in Expo SDK 52, then Google Play Store forced me to upgrade to 53, then I upgraded to 53 and boom, suddenly this error about import.meta. |
|
You can use this babel config to fix it on RN with expo. module.exports = function (api) {
api.cache(true);
return {
presets: [
[
'babel-preset-expo',
{
unstable_transformImportMeta: true,
},
],
],
};
}; |
|
Any updates on this? Is the issue in |
I fixed it by placing the react-native in first `const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config'); /**
module.exports = wrapWithReanimatedMetroConfig( |
|
Subscribing to track resolution — affected by this in an Expo 55 + React Native Web project. Currently using the |
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:exportsby 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-nativespecific 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:exportssupport. Configuring metro.config.js for Expo with this should help:Reproduction Link
https://github.com/byCedric/jotai-expo-53-issue
npm run startAll reactions