Kabir Roy Kabir Roy - 1 year ago 82
Git Question

Can Angular 2 components be externalised?


Is it possible to have something like

for components in an Angular 2 app?

Long Version

The components of our application are being developed independently. They have their own services, constants and internationalisation strings. Every time there is an update or change to a component the application version is updated. Is there a way we could just version a component and have separate repositories for each component; each being stated as a dependency of the main app?

My Thoughts

  • Create a dummy app on each machine that is used to develop a component

  • Work with the component and commit it to a repository

  • The main app's build process specifies those repositories as dependency and pulls them (specific version) during build time.

  • Another task copies them into the application directory (from


Has anyone already done this before? Is there a better way of doing this?

Answer Source

It's simpler than I thought. Just move the component files out of the app as a separate module. npm install --save it to the app and update the app.module.ts file to point at it. Angular CLI will automatically handle the rest.


import { ProfileCardComponent } from '@yoloinc/profile-card-component/profile-card.component';

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download