title: Cannot find module './sections/lazy/lazy.module.ngfactory' Error in Angular 2 Webpack + AOT setup
body: <p>I have been trying for a while to get a lazy loaded module to work in a simple AOT + Webpack Angular 2 setup.</p>
  
  <p>Here are my core settings, if anything else is useful to create more context please let me know and I will update the question.</p>
  
  <p><strong>tsconfig.json</strong></p>
  
  <pre><code>{
    "compilerOptions": {
      "target": "es5",
      "module": "commonjs",
      "declaration": false,
      "removeComments": true,
      "noLib": false,
      "emitDecoratorMetadata": true,
      "experimentalDecorators": true,
      "lib": ["dom", "es6"],
      "sourceMap": true,
      "pretty": true,
      "allowUnreachableCode": false,
      "allowUnusedLabels": false,
      "noImplicitAny": true,
      "noImplicitReturns": true,
      "noImplicitUseStrict": false,
      "noFallthroughCasesInSwitch": true,
      "moduleResolution": "node",
      "outDir": "build/tmp",
      "typeRoots": [
        "./node_modules/@types"
      ],
      "types": [
        "node",
        "jasmine"
      ]
    },
    "exclude": [
      "build",
      "dist",
      "node_modules",
      "src/main.aot.ts",
      "tmp"
    ],
    "angularCompilerOptions": {
      "debug": true,
      "genDir": "build",
      "skipMetadataEmit": true
    },
    "compileOnSave": false,
    "buildOnSave": false
  }
  </code></pre>
  
  <p><strong>app.routing.ts</strong></p>
  
  <pre><code>import { NgModule } from '@angular/core';
  import { Routes, RouterModule } from '@angular/router';
  
  export const routes: Routes = [
    { path: 'lazy', loadChildren: './sections/lazy/lazy.module#RecipesModule' },
  ];
  
  @NgModule({
    imports: [RouterModule.forRoot(routes)],
    exports: [RouterModule],
  })
  export class AppRoutingModule { }
  </code></pre>
  
  <p><strong>webpack.prod.js</strong></p>
  
  <pre><code>// ...
  module: {
    rules: [
      {
        test: /\.ts$/,
        loader: '@ngtools/webpack',
      }
    ]
  }
  // ...
  plugins: [
    // ...
    new AotPlugin({
      tsConfigPath: './tsconfig.json',
      entryModule: helpers.root('src/app/app.module#AppModule')
    }),
    // ...
  ]
  // ...
  </code></pre>
  
  <p>The build process completes without any problem but the error <code>Error: Uncaught (in promise): Error: Cannot find module './sections/lazy/lazy.module.ngfactory'.</code> occurs when I try to navigate to the <code>/lazy</code> url.</p>
  
  <p>Also running the app in development/JIT works without any issue.</p>
  
  <p>Do you spot any problem? </p>
  
  <p>Thanks</p>