-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Project Structure Proposal #6292
Comments
Honestly, to me, the only real issue was these two extra folders living at the root. As projects get bigger and new tools are added, I like to keep the structure sleek w/o two extra folders on top of that. In all my projects I've been successfully changing the structure and moving them to See for example this project (universal):
Having said so, that would've been my main motivation. From I am mainly concerned about limitations this means for native code there's usually laying in the app. Sometimes you have to perform extra actions in AppDelegate (well, we could wrap that in a yet another package, called On the other hand, the current state of things is far from perfect, mainly when it comes down to running Regarding point 5, I think it could be just a matter of a flag in rn-cli.config.js, e.g. |
@grabbou thanks for your comments. I don't have much context on iOS (I mostly work on Android) -- it sounds like we've got some unique challenges there but it also sounds like they could be solved by adding more configuration to the generation process?
That's pretty smart, I like it. |
I'm writing a React Native project focusing on iOS to start. I consider this a "pure" RN project as opposed to just "RN embedded" because the vast majority of it has been implemented in React Native, but even so I've had to make changes to my
I've also made some minor customization to my build process, specifically allowing for local/staging/prod builds with different endpoints, that I wouldn't want to be overwritten. All of these (maybe with the exception of 5) are pretty common needs even in "pure RN" apps, and I think it would be good for a solution to keep those things easy to do. Anecdotally, I haven't had too much trouble with the current |
Not entirely sure what's the best approach. But I'll share my thoughts. I think changing the Native files is very common for lots of people. For example, on Android, say you want to add push notifications, analytics etc. you cannot do that without touching native files. Often third party plugins require changes to native files to work. And many other cases @corbt and @grabbou mentioned. So people often actually need to change certain files. Another use case is to change package name of the project. Currently we generate the package name from the If we solve the package name problem, now comes the auto-generated bolierplate issue. I think the first thing we should do is try to move as many files into the library itself, for example, what we did with the Once we do that, it should be pretty trivial to upgrade I think. We could still move the |
It would be great to have an easier upgrade process. Writing custom stuff is my main concern in this. Using rnpm to do this seems fine. Regarding the app delegate and root view controller, perhaps there can be a programmatic way to hook into it from a custom rnpm module middleware style to help attach launch screens, change the dev server ip, etc? |
Echoing the comments above, it's very common to change your AppDelegate/Info.plist and MainActivity/AndroidManifest.xml. I'm afraid that if we try to hide these through a leaky abstraction we will add more complexity than we are shaving off by simplifying the upgrade process. |
@brentvatne +1 that, for instance - we add custom fonts with rnpm to Info.plist since that's easy, but there might be some other cases we simply don't think about at the moment which will lead users to fill in an issue/feature request later. |
Hiding core react-native project stuff in I like the idea, but maybe just rename it to |
@facebook-github-bot label For Discussion |
For
|
We are already working on that with @Kureev so plugins can specify custom config they ask users for (e.g. Google Analytics token) and we will use prompt module to display a nicely formatted interactive question during
That's also in the scope of ^ - we are planning to add some places in these files where plugins can hook with their custom code, e.g. to register for push notifications or to register Sentry (iOS) in e.g. |
Summary:The goal is to minimize the number of files we need to bootstrap. This allows us to make the upgrade process smoother for everyone. If someone needs to customize the file, we already provide some config options. The ability to copy the file and modify it is always there for those few who need it. **Test plan** Generate a new project with the updated template. The app should build and run fine both in debug and production mode. Related #6292 Closes #6610 Differential Revision: D3109099 Pulled By: foghina fb-gh-sync-id: 13fc89e60daed30bf6349e532a140c1b6f8f053a fbshipit-source-id: 13fc89e60daed30bf6349e532a140c1b6f8f053a
I appreciate the discussion about project structure but the proposal is very narrow. Projects structures are what they need to be for a variety of reasons and increasingly due to the fact they must also fit into devops scenarios with continuous integrations and deployment. In general I think you will find developers don't want:
What I believe we'd like to see generally:
|
Summary:The goal is to minimize the number of files we need to bootstrap. This allows us to make the upgrade process smoother for everyone. If someone needs to customize the file, we already provide some config options. The ability to copy the file and modify it is always there for those few who need it. **Test plan** Generate a new project with the updated template. The app should build and run fine both in debug and production mode. Related facebook#6292 Closes facebook#6610 Differential Revision: D3109099 Pulled By: foghina fb-gh-sync-id: 13fc89e60daed30bf6349e532a140c1b6f8f053a fbshipit-source-id: 13fc89e60daed30bf6349e532a140c1b6f8f053a
Since this is "for discussion" and the discussion seems to have petered out I am closing this issue. |
The problem
We generate a lot of boilerplate code (the
ios/
andandroid/
folders containing the native app code) into people's projects / repositories. This is not uncommon, a lot of frameworks do this, but they generally do it for other reasons. They do it to impose a certain structure that they then expect when running the app. We only expect an index.js file, the rest of the stuff that we generate is just boilerplate that most people never change and/or have a hard time maintaining.The solution
Generate the Android / iOS apps in a hidden, vcs-ignored folder (e.g.
.reactnative/
). This will remove the boilerplate from people's projects and give us greater control over the app templates. It also gives us the freedom to re-generate the templates whenever we please (e.g. when you switch to a newer version of React Native), since they will never be touched by developers. This also means no moreupgrade
command, making switching to a new React Native version much easier.Essentially, the new structure would look something like this:
Challenges
package.json
(can we, or do we have to invent another file?) and read them at generation time.run-android
.Going forward
First, I'm curious what people's thoughts are. Would this be valuable? Are there any huge blockers that I'm not seeing? For example, I'm worried about all rnpm modules having to match a project's react-native dependency version making upgrading hard. But I'm guessing this is already an issue.
Second, I will not have time to work on this anytime soon. I might in the future, but no guarantees. I'd be thrilled to have someone in the community own this though and more than happy to review PRs.
The text was updated successfully, but these errors were encountered: