lazyloader不适用于AOT生产模式angular-cli

时间:2017-05-24 16:19:17

标签: angular2-routing angular-cli lazyload

我正在使用angular-cli和lazyloader进行路由。

import io buf = io.BufferedRandom(io.BytesIO()) buf.write(b"a") buf.write(b"b") buf.seek(0) while True: print "reading" a = buf.read(1024) if not a: break print "read: {}".format(a) buf.close() 对我有用,但在将项目构建为生产模式后,它根本不起作用。

这是我的app.routing.ts

ng serve

这是我在import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import { MainComponent } from './main/main.component'; import { AuthGuard } from './core/guards/index'; //Layouts import { LoginComponent } from './login/login.component'; export const routes: Routes = [ { path: 'login', component: LoginComponent }, { path: '', component: MainComponent, children: [ { path: '', loadChildren: './main/main.module#MainModule' } ], canActivate: [AuthGuard] },{ path: '**', redirectTo: 'login' } ]; @NgModule({ imports: [ RouterModule.forRoot(routes) ], exports: [ RouterModule ] }) export class AppRoutingModule {} ng build --prod --aot之后得到的错误。

ng serve --prod

以下是浏览器控制台的屏幕截图。

enter image description here

我的路由配置有什么问题? PP:ERROR Error: Uncaught (in promise): Error: Cannot find module './app/main/main.module'. Error: Cannot find module './app/main/main.module'. at t (main.1f6da18….bundle.js:1) at t.loadAndCompile (vendor.490f84a….bundle.js:379) at t.load (vendor.490f84a….bundle.js:379) at t.loadModuleFactory (vendor.490f84a….bundle.js:428) at t.load (vendor.490f84a….bundle.js:428) at e.project (vendor.490f84a….bundle.js:428) at e.XO5T.e._tryNext (vendor.490f84a….bundle.js:897) at e.XO5T.e._next (vendor.490f84a….bundle.js:897) at e.next (vendor.490f84a….bundle.js:897) at e.RRVv.e._subscribe (vendor.490f84a….bundle.js:736) at t (main.1f6da18….bundle.js:1) at t.loadAndCompile (vendor.490f84a….bundle.js:379) at t.load (vendor.490f84a….bundle.js:379) at t.loadModuleFactory (vendor.490f84a….bundle.js:428) at t.load (vendor.490f84a….bundle.js:428) at e.project (vendor.490f84a….bundle.js:428) at e.XO5T.e._tryNext (vendor.490f84a….bundle.js:897) at e.XO5T.e._next (vendor.490f84a….bundle.js:897) at e.next (vendor.490f84a….bundle.js:897) at e.RRVv.e._subscribe (vendor.490f84a….bundle.js:736) at u (polyfills.1e19b2c….bundle.js:43) at u (polyfills.1e19b2c….bundle.js:43) at polyfills.1e19b2c….bundle.js:43 at t.invokeTask (polyfills.1e19b2c….bundle.js:36) at Object.onInvokeTask (vendor.490f84a….bundle.js:365) at t.invokeTask (polyfills.1e19b2c….bundle.js:36) at r.runTask (polyfills.1e19b2c….bundle.js:36) at o (polyfills.1e19b2c….bundle.js:36) 正在处理任何错误。

1 个答案:

答案 0 :(得分:4)

此问题来自angular2-busy模块。

https://www.npmjs.com/package/angular2-busy

从项目解决问题中删除它。