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

fix: Improve support for web projects #762

Merged
merged 1 commit into from
Nov 19, 2024

Conversation

amutsch
Copy link
Contributor

@amutsch amutsch commented Nov 17, 2024

This PR adds 1 new web entry point and updates imports for 2 copied types. React-native-web will no longer be necessary to use this library with webpack/vite configurations.

In order to fix this I did have to duplicate the 2 type definitions in NativeMmkv.ts. React Native Codegen requires those types be in the file with the spec definition. In doing so accessing those types causes imports to react native. For Now duplicate the types with notes so the project can be built to work on web and react native.

Starting with 3.x webpack required the addition of react-native-web to work.
Webpack would throw errors even with react-native-web but those errors seemed to be ignored and everything worked as expected.
Vite configuration will not ignore those errors even with react-native-web.

resolves: #712 and #731

Testing Notes:
Besides the items listed in guidelines I use npm file link in large project with RN 75.3, Webpack web config and latest MMKV with these changes. Tested Ios, Android, Webpack Web App. Made sure any of the MMKV storages were cleared so they would rebuild and update and everything was working as expected in my app.

Starting with 3.x webpack required the addition of react-native-web to work.  Webpack would throw errors even with react-native-web but those errors seemed to be ignored and everything worked as expected.
Vite configuration will not ignore those errors even with react-native-web.  This re-arranges some code and adds some new web entry points.  React-native-web will no longer be necessary to use this library with webpack/vite configurations.
@mrousavy
Copy link
Owner

This is good stuff, thank you!!

@mrousavy mrousavy merged commit 02a00ae into mrousavy:main Nov 19, 2024
3 checks passed
@amutsch amutsch deleted the fix/amutsch/WebSupportImprovements branch November 20, 2024 01:06
@dppo
Copy link

dppo commented Nov 26, 2024

This is good stuff, thank you!!

Is it possible to release a new version?

@dppo
Copy link

dppo commented Dec 17, 2024

@amutsch @mrousavy Can you take some time to release a new version? Thank you so much

@mrousavy
Copy link
Owner

done - released 3.2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

v3 beta requires RN-web to use in a web build
3 participants