fix: Improve support for web projects #762
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.