v3 beta requires RN-web to use in a web build
In V2 it did not require RN web to use the library with react native and a separate react web app pulling in a Shared JS only library with MMKV to zustand integration). When I moved to V3(RN 74 with Fabric enabled) it required me to add RN Web to use the module with my web setup.
Thanks for the v3 beta BTW, working great
Guten Tag, Hans here.
[!NOTE] New features, bugfixes, updates and other improvements are all handled mostly by
@mrousavyin his free time. To support@mrousavy, please consider 💖 sponsoring him on GitHub 💖. Sponsored issues will be prioritized.
I'm planning to take a look at this issue and test it this weekend, I reviewed code tonight and the fix seems straight forward.
Quick summary of items. There are 2 types in NativeMmkv.ts that are pulled into MMKV that cause a whole chain of RN code to be pulled in. Move the 2 types into Types file and update imports as needed.
The AppState usage in MMKV.ts needs to be handled, likely push that out to another file so I can add the web overload. Need to determine if there is an equivalent listener for memoryWarning I can attach for web.
Looks like separating the interfaces to disconnect pulling in react-native is not currently possible due to some issues in codegen. I'll hold my changes to a future date where codegen allows this.
hi @amutsch @mrousavy does it mean that mmkv is dropping support for react-native-web when using v3?
@gituser8796 , no the lib still works great in web. With 2.x a web build did not require react-native-web to build with this lib. With 3.x react-native-web alias is required to use the lib in a web build.
Thanks for letting me know @amutsch !
With 3.x react-native-web alias is required to use the lib in a web build.
How so? Can this be avoided? If yes I'd appreciate any help / PRs here, I am not using react-native-mmkv in web myself. 🙏
@mrousavy I have changes but until some changes occur in react native codgen we are stuck. I will open a new issue with pr if codegen updates to support this.
@amutsch do you happen to have a PR for web?
@gituser8796 if you add react-native-web there will be some warnings but the module will work fine. react-native-codegen currently does not support separating the turbomodule interface from the spec definition which is causing the RN code to need to be pulled in. I have changes in a branch can fix the RN-web requirement once codegen supports separating interface and module definition
@mrousavy I looked into a vite issue for someone and it looks like some of the exploratory work I was doing for a PR for this will be needed to get react-native-mmkv to work with vite in web project. If you can re-open this I will try and get a PR. It is fixable just one thing I don't like with how I need to fix that I'm working out which I will either document on PR or get fixed