Closed kastriotkastrati closed 2 years ago
Alright, this is a good one! I will take a look.
I think this is caused by TinyBase using the exports
field, not supported by Metro as per https://github.com/facebook/metro/issues/670 - I'm looking at workarounds.
OK, fixed. Please update to v1.3.2. This adds a "react-native"
field to package.json
that allows Metro to find the file directly (since it doesn't currently support exports
).
The ui-react
library works too! - because it doesn't rely on the HTML DOM. But Note that until Metro fixes https://github.com/facebook/metro/issues/670 you will still have to be slightly creative and reference it explicitly from the lib folder directly:
Have fun and let me know how it goes!
@kastriotkastrati how is your experience going so far?
@jamesgpearce Hello, It's going really well. Typescript throws me errors whenever I import something from 'lib/ui-react' since tinybase.d.ts does not export ui-react and that's where the imports are looking for the types. I don't know if there's something wrong with my ts configuration or whether this is expected (as you know there's a perfectly fine ui-react types file wherefrom I would have rather gotten the types). To solve my issues, I've either added @ts-ignore on the imports or primarily used other means of recreating the behavior of ui-react. I'm also obviously using a custom persister to accommodate for react-native. I've been making some helper functions to serve me somewhat like a mini-ORM, which I'm curious to know whether you think they're something that tinybase should have.
Oh no! I wonder if you can use tsconfig
to force it to resolve the .d.ts
at that path? Or try some explicit things in the typesVersions
field in package.json. Happy to merge in anything that fixes it until https://github.com/facebook/metro/issues/670 happens.
Describe the bug
Hello, I'm trying to use tinybase for a project with react-native and I keep getting this error:
In my opinion, looks like metro has issues with the way the package is exported in package.json and cannot resolve the correct path.
Your Example Website or App
React native is not an option in stackblitz
Steps to Reproduce the Bug or Issue
Expected behavior
I would expect tinybase to work similar to how it does in a react or next app, with webpack.
Screenshots or Videos
No response
Platform
Additional context
No response