-
Notifications
You must be signed in to change notification settings - Fork 18
Trouble importing with paths like: '@coolmono/cool-library/CoolComponent' #10
Comments
I'm going to try to reproduce this in a none expo project. If the issue is also there I'll hit up the @nrwl/react-native issues and link to it from here. |
Hi, @Enricopv. First thanks for the clear exposition of the issue. I'll look in to it the next weekend. If the issue is also present in the Two words about this issue, metro let you opt in and customize the module resolution process. And that is what this pachage and the @nrwl one do. The problem is that in order to resolve where the libs are inside the monorepo we use a package called A "workaround" could be to define each library by hand in the tsconfig, but obviusly is not a definitive solution. |
@JacopoPatroclo thanks for explaining where the issue might be. I'll take a stab at the path resolution issue! |
How's the stabbing going? 😄 |
I was able to find the problem @JacopoPatroclo was referring to and found a way to hack it, but have left it alone as I had to focus on other things for work. I'll be looking at it again this week as it's becoming more important for us to work this out. The problem is in this file here. The I got this to work for a specific file by adding the path for it manually instead of the
Of course this would need to be done for each file imported in the pattern mentioned above in the issue. I plan on writing a fix for our needs soon, will share here. The solution might be a little hacky, but if it's cool with people I'll make a pull request. |
I get the below issue when I try to import using something like:
Error 😞
All of those three patterns of importing works fine in my Next.js apps and all my React or normal JS libraries. Metro seems to be the one having the issue.
I prefer to import with
@mono/lib/component
as a general convention because I don't want to import all the components / utilities of that library (Next.js chokes really hard in local development on > 100mb pages because @mono/lib will have a lot of components). Obviously for react-native projects I can just do@mono/lib
, but my other libs use@mono/lib/component
and this error pops up again.Maybe I'm just a newb and there's a way to import with
@mono/lib
(with an index.ts with a lot of exports) where I don't get absolutely everything from it. Maybe this might be a more appropriate issue to report in the nx-react-native repo?My tsconfig.base.json looks something like this:
My package.json
I enjoy using this tool in my monorep. Thanks for all the work you do!
The text was updated successfully, but these errors were encountered: