ngx-rocket / generator-ngx-rocket

:rocket: Extensible Angular 14+ enterprise-grade project generator
https://ngx-rocket.github.io/
MIT License
1.53k stars 216 forks source link

Adding monorepo as a possible repository option? #499

Open duydnguyen07 opened 5 years ago

duydnguyen07 commented 5 years ago

Would it be possible to add a monorepo option when generating a web app?

Something that looks like this https://github.com/kievsash/Core-App-monorepo ?

I'm submitting a...

Current behavior

There isn't really a way to create a monorepo setup

Expected behavior

A new option called "Web app (monorepo)" or something like that will generate a monorepo setup.

Minimal reproduction of the problem with instructions

Environment




Others:

sinedied commented 5 years ago

Basically, what you want is this: https://angular.io/guide/file-structure#multiple-projects ?

Because the repo you linked contains both an app at the root and a workspace, which is something you can already do with the current generator and the ng cli: just call ng generate application my-app to add an additional app after the initial ngx project is generated.

I'm not sure I understand what you really wants here?

davidecampello commented 5 years ago

Hi, I'm looking for the same thing because I would like to have a monorepo for a project that have multiple angular (web/desktop) webapp and multiple ionic app with some shared modules like services and components. If I create the new application with ng generate application I later have errors running ng serve with --project option. Furthermore I'm not sure that with Ionic this solution will work because config.xml is in the root directory. Have you found a solution?

duydnguyen07 commented 5 years ago

@sinedied true. I guess what I was wishing for was that the shell code can exist in the src folder and then the features can be grouped in applications in the project folder. The use case for me is that I have a dashboard that has some shared features and some distinct features for 2 different app and currently, I have to use 2 separate installations or risk bundling things I don't need using the monolithic application approach. It would be helpful to give me the choice from the beginning to set up the app in such a way that I can easily add a new project without undoing a lot of the boilerplate code. Maybe this is just a nice to have.

dopsonbr commented 5 years ago

Personally I would love to see something that is a cross between this and setup that yarn create nx-workspace $workspace-name --preset=angular-nest gives you. Has there been any thought to collaborating with the nrwl folks?

sinedied commented 5 years ago

@dopsonbr nrwl includes the monorepo approach in its core, but is based entirely on angular schematics while this project use Yeoman, so the integration would be difficult.

I don't have much experience in Angular monorepos, but if anyone has some thoughts on what needs to be done to make this project "monorepo friendly", feel free to suggests changes to be made and/or propose a PR. I could see a --monorepo or --workspace option flag being added to support that.

AFAIK, it's mainly a matter of where to put the files/folder and configs, + tweaks to angular.json?

duydnguyen07 commented 5 years ago

Well in a simplistic sense, it is just that. However, the topic is a lot more complex than that. I'm still investigating which approach is the best for monorepo. A few approaches that are worth looking into are lerna, nx from nrwl, and simply just using ng-packagr for libs and the app is a combination of those libs. I will give more detailed findings soon after a few experiments and more research on pros and cons.