title: Angular2: Loading modules dynamically from a given folder
body: <pre><code>app
   |-plugins
         |-plugin1
             |-config.json
             |-plugin1.module.ts
             |-plugin1.component.ts
  
         |-plugin2
             |-config.json
             |-plugin2.module.ts
             |-plugin2.component.ts
  </code></pre>
  
  <p>As you can see above, I have <strong><em>"app/plugins"</em></strong> folder, which contains plugins. Each plugin will contain one "config.json" file which will tell some configuration including -</p>
  
  <pre><code>{
     path: "feature1",
     moduleFile: "feature1.module",
     moduleClassName: "Feature1Module"
  }
  </code></pre>
  
  <p>So what I want is, before application bootstrap it will scan the <strong><em>"app/plugins"</em></strong> folder and load all plugin configurations, and lazily register all module routes. For above example the route will be </p>
  
  <pre><code>{
       path: "feature1",
       loadChildren: "app/plugins/plugin1/plugin1.module#Plugin1Module"
  }
  </code></pre>
  
  <p>That way, we can drop new plugin into plugin folder and refresh the application, and our newly dropped plugin is up and running.</p>
  
  <p>Anyone knows how can I achieve this?</p>
  
  <p>NOTE: <em>I am on angular2 latest(2.1.0)</em></p>