Import modules using package.json name in react-native
I am developing an app on react-native and we want to use absolute path imports in our project.
For this, we are using the a workaround described here: https://github.com/facebook/react-native/issues/3099#issuecomment-221815006
The idea is that using be main package.json name we can import modules using absolute paths. This works perfectly and react-native builds without issues.
The problem is that Webstorm can't resolve these paths, thus I an losing the goToDeclaration mechanism which is very useful.
How can I configure Webstorm to be able to resolve these kinds of paths?
Thank you
Please sign in to leave a comment.
WebStorm provides no support for this React Native hack (not officially documented anywhere, as far as I can tell). If you miss this feature, please follow WEB-23221 for updates.
Marking a parent folder of
@subdirectoryspecified in package.json as Resource root (note: not the subdirectory itself, but its parent dir!) should help to work out the issue - unless the@subdirectorydoesn't match actual folder nameThanks for your feedback. Marking the parent folder as a Resource root resolved my the paths correctly. I will follow the issue though for updates because I believe it should be resolved by default
What about if the subdirectory does not match the actual folder name? I'm having the same issue in PyCharm
No workarounds can be suggested then. Please vote for https://youtrack.jetbrains.com/issue/WEB-23221