Issues with platform-specific React Native files #4
Comments
Thanks for letting me know. I'm sure it's fixable. Do you know of any open source repo that has a similar problem/file structure, so that I can test it on that? |
Hey @smeijer. I'm not aware of too many good open source examples, so I've created a small dummy repo to test on: https://github.com/salockhart/RNPlatformSpecificCodeExample It's super barebones but should suffice. Here's an example of the output:
|
Thanks for the repo. That definitely helps. I do have a hard time understanding the dependency tree here though. Take the
When I have an And do I need all of those files? Or can I have any of those at random? |
The import gets resolved at build time, so I don't think that you would have both
|
But only if they exist, and if they do not exist, |
Yes that is correct |
I think I have done it. I'll test it a bit more, and will release it this week. Thanks for the info! |
This would be really handy to have for RN projects. Is there any update on the progress? |
@smeijer Thank you so much for looking into this! This feature would be super useful for React Native. If you need any help I'm happy to lend a second pair of eyes! |
Sorry, even though I had a working version, it took me a while to commit. Mostly because I didn't really like the solution. I believe I've now found a better way to support this, and the commit has been pushed. It's way more generic, and adds support for build configs like react native, but also other projects that have multiple build targets. I'll release this soon. All that's left is add some presets / auto detection so that you don't need to setup complicated unimportedrc config files. |
Wrong button 😅 |
Released in |
Hey!
I was running this on my React Native project, and I noticed that it wasn't able to follow an import such as
./User
and resolve it to./User.ios.tsx
and./User.android.tsx
.I realise this is an edge-case and might be difficult to solve since IIRC these special extensions are handled by Metro. Just wanted to surface this in case anyone else has the same issue. Luckily I have very few platform-specific files so this tool is still super valuable.
Thanks!
The text was updated successfully, but these errors were encountered: