react-refresh-plugin crashes if createStorage is even referenced in a file running on expo web #2224
Unanswered
jrobber
asked this question in
Bug report
Replies: 3 comments
|
We still use discussions for digging into bugs. Maybe we should change the template. Do you know if you fix doesn't affect others? Feel free to open a PR if you have an idea for a solution. |
0 replies
|
Can anyone investigate why |
0 replies
|
Even though the stack trace starts from |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Summary
I'm using expo's web build using their metro config option
(https://docs.expo.dev/workflow/web/)
(https://docs.expo.dev/guides/customizing-metro/)
If
createJSONStorage(() => AsyncStorage)is in the code, anywhere, even if it's in an if statement that is never true, an error is thrown in the console and the page fails to load:Cannot read properties of undefined (reading 'jotaiAtomCache')Digging in, the only place 'jotaiAtomCache' is used as a property is in the react-refresh plugin code and it's always to the left of
globalThis.jotaiAtomCachein a template string. If I comment out:'jotai/babel/plugin-react-refresh',from babel.config.js the bug disappears.Link to reproduction
https://github.com/jrobber/jotai-react-refresh-bug
npm inpm run web> Check the browsers logsCheck List
Please do not ask questions in issues.
Please include a minimal reproduction.
I've added a link to a typescript playground or codesandbox with a minimal reproduction.
I've attached a repo. Due to the nature of the build behind this bug it is not possible to setup CodeSandbox with the issue at this time.
All reactions