External dynamic load modules in angular2

I have an application written in node.js that hosts an angular2 application. The entire application uses lazy loading as follows:

 export const routes: Routes = [ { path: '', component: MyComponent, children: [ { path: 'lazy', loadChildren: '../common/lazy/lazy.module#LazyModule' } }] 

Another team in my company is creating a different kind of software, but we want to reuse some of our modules. We don’t want to share a strict code base, but publicly publish the module and load it by the application itself, so we can do something like this

 export const externalRoutes: Routes = [ { path: 'externalModule', loadChildren: 'http://mymodules.host/lazy.module#LazyModule' }] 

Can I load a module into a live application? I know something like a dynamic component loader, but we need to load a module with a lot of components in it.

+5
source share

Source: https://habr.com/ru/post/1272001/


All Articles