app
|-plugins
|-plugin1
|-config.json
|-plugin1.module.ts
|-plugin1.component.ts
|-plugin2
|-config.json
|-plugin2.module.ts
|-plugin2.component.ts
As you can see above, I have "app/plugins" folder, which contains plugins. Each plugin will contain one "config.json" file which will tell some configuration including -
{
path: "feature1",
moduleFile: "feature1.module",
moduleClassName: "Feature1Module"
}
So what I want is, before application bootstrap it will scan the "app/plugins" folder and load all plugin configurations, and lazily register all module routes. For above example the route will be
{
path: "feature1",
loadChildren: "app/plugins/plugin1/plugin1.module#Plugin1Module"
}
That way, we can drop new plugin into plugin folder and refresh the application, and our newly dropped plugin is up and running.
Anyone knows how can I achieve this?
NOTE: I am on angular2 latest(2.1.0)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…