discussions-and-proposals icon indicating copy to clipboard operation
discussions-and-proposals copied to clipboard

Are RN projects in (still) subfolders supported?

Open JonnyBurger opened this issue 6 years ago • 7 comments

Introduction

I want to inquire and discuss about support for RN apps that live in subdirectories, like app/.

The Core of It

My project structure is that I have server, website and React Native app everything in one. My React Native app is in a subfolder app. I created this structure over 2 years ago and that worked kinda fine. There is a --root option for Metro, and project.ext.react also allows me to specify root: "../../.." etc. I've ran RN this way for a long time now, but now I see that in the tools, it is more and more often assumed that for example the xcodeproj is in a specific location and or that the modules directory is ../node_modules relative to the RN app. One example is the new React Native Autolinking, which does not seem to work with my structure at all. react-native link seems to work, but react-native unlink does not seem to.

Discussion points

  • Is having a RN app in a subdirectory like app/ supported? Has it ever been?
  • Should we file issues for tooling that does not work in subdirectories?

JonnyBurger avatar Jul 12 '19 06:07 JonnyBurger

👋 can I ask you a follow up? Isn't this simply a monorepo structure? 🤔

kelset avatar Jul 12 '19 22:07 kelset

@kelset No, I think under a monorepo most people understand a repo with multiple folders that each have a package.json and node_modules. Then the code gets linked together using symlinks using tools like Lerna or Yarn workspaces.

I mean structures that only have 1 package.json and don't use tools to link different packages together.

The important difference in this case is that monorepos still have their modules installed in ../node_modules relative the the Xcode project, while for subfolders the modules are for example in ../../node_modules.

JonnyBurger avatar Jul 13 '19 09:07 JonnyBurger

Oh, I see - thanks for clarifying!

Shouldn't this be an issue to be opened in Metro then? If I understand correctly, it's a regression related to the bundler no?

kelset avatar Jul 13 '19 15:07 kelset

With all the mentions of link and unlink, it is probably worth sharing with the CLI maintainers too.

elicwhite avatar Jul 14 '19 04:07 elicwhite

let's keep it here for now then

kelset avatar Jul 15 '19 17:07 kelset

Thanks for the responses! I only wanted to ask if this is supposed to be a supported way of running a RN project. In that sense, it seems like it is and therefore I will file issues I encounter on the next best occasion.

You can close this issue if you like.

JonnyBurger avatar Jul 18 '19 16:07 JonnyBurger

@JonnyBurger are you still using this structure? How are you finding it?

I'm looking for resources about the best way for sharing code across multiple React Native apps that are in the same folder and might open a discussion asking about how people are doing this.

henrymoulton avatar Aug 05 '20 11:08 henrymoulton