0
votes

I have two Angular applications. Each have one main Module and some components. I want to have a third Angular project, that uses them. How can I do that?

I think I should somehow package each application and then install it in the new Angular project, but I think it's possible to package only Library projects, not Application projects.

I know about Angular Elements, but I think packaging each project files will end up with conflicts, because they create some common files like polyfills.js and runtime.js.

1

1 Answers

0
votes

Angular Elements is the tooling to not building your App as an actual Angular Application, but it provides tooling to build your sources as a web component. If your App is more a widget and it will possibly be used by other frameworks than Angular or without a framework, you could consider this path.

Using a Library could be one option if you want to distribute your sub-apps over the NPM channel. You may be working in a corporate environment and you have wrapped the NPM packages behind a private repository / paying for private on npmjs or you are open sourcing the whole sub application. Therefore you could build a library with features reused. Your lib code is highly configurable then. I would try this path. You can extend the Lib code with schematics, to enable easier integration in other projects. Using the library has many topics to consider, like versioning of the lib.

If you are using git and you are the only consumer of the sub apps, you could checkout git`s Submodules feature and configuring sub project and third project accordingly. Then you are able to bi-directionally develop main and sub-apps.

All in all I would have a look into Angular-Libraries and schematics.

https://angular.io/guide/schematics https://blog.angular.io/schematics-an-introduction-dc1dfbc2a2b2

https://angular.io/guide/creating-libraries