title: Angular 5 : Lazy Loading is not working properly with ng build - -prod with Angular-CLI 1.7.x
body: <p>I'm working under :</p>
  
  <ul>
  <li>Angular: <strong>5.2.6</strong></li>
  <li>Angular-CLI : <strong>1.7.x</strong></li>
  </ul>
  
  <p>I have this routing file under my app <em>(where i ve some lazy loading modules )</em> :</p>
  
  <pre><code>const homeRoutes: Routes = [
    {
      path: 'home', component: HomeComponent,
      children: [
          ....
        {
          path: 'admin',
          loadChildren: 'app/home/admin/admin.module#AdminModule',
          canActivate: [AuthGuardAdmin]
        },
      ]
    },
  ];
  
  @NgModule({
    imports: [
      CommonModule,
      RouterModule.forChild(homeRoutes)
    ],
    exports: [
      RouterModule
    ],
    declarations: []
  })
  export class HomeRoutingModule { }
  </code></pre>
  
  <p>Whle running <strong>ng serve</strong> , the lazy loading did not work , and i get this error :</p>
  
  <pre><code>&gt;     core.js:1448 ERROR Error: Uncaught (in promise): TypeError: undefined is not a function
  &gt;     TypeError: undefined is not a function
  </code></pre>
  
  <p>Whith some googling i was told to change my lazy loading like this :</p>
  
  <pre><code>  {
      path: 'admin',
      loadChildren: ()=&gt; AdminModule,
      canActivate: [AuthGuardAdmin]
    },
  </code></pre>
  
  <p>this works in <strong>development mode</strong> <strong>:)</strong>  , but when running ng <strong>build --prod</strong> , it fails again throwing this : </p>
  
  <pre><code>ERROR in Error during template compile of 'HomeRoutingModule'
    Function expressions are not supported in decorators in 'ɵ0'
      'ɵ0' contains the error at app/home/home-routing/home-routing.module.ts(182,23)
        Consider changing the function expression into an exported function.
  </code></pre>
  
  <p>So i'm afraid that i'm not able to get it work.</p>
  
  <p>I  don t want to downgrade <strong>angular-cli to 1.6.x</strong>  for some other reasons .</p>
  
  <p><strong>So any ideas of how to fix it ??</strong></p>