How to dynamically load an external angular 2 module (for example, served through an external module.bundle.js)

I can dynamically load local modules, as someone else in plunker did here . But how to load an external module, say, from a separate js package served by another service. In the example plunker src / app.ts has:

constructor(private viewref: ViewContainerRef, private resolver: ComponentFactoryResolver, private loader: SystemJsNgModuleLoader, private compiler: Compiler){ this.module = new ModuleNode(); //can I make this a non-local script reference somehow? //like to http://example.net/external.module.bundle.js this.module.modulePath = "src/dynamic.module#DynamicModule"; this.module.componentName = "TestComponent"; } 

Is there any way to achieve this?

EDIT: To clarify, the scenario is that a group of microservices (built, deployed, etc. on their own) creates a spa. Therefore, my microservice wants to dynamically load a component / module from the bundle.js package serviced by another microservice. This is why I do not have a module / package at compile time. The only contract between the two microservices is the package file URL. If they update a component / module, a hard update should reflect the changes without redeploying my microservice.

+6
source share

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


All Articles