我有一个名为myapp
. 我已将我的路线配置如下:
const routes: Routes = [
{ path: 'home', loadChildren: 'libs/home/home.module#HomeModule'},
{ path: 'admin', loadChildren: 'libs/admin/admin.module#AdminModule' },
{ path: '', redirectTo: '/home', pathMatch: 'full' },
{ path: '**', component: PageNotFoundComponent }
];
Myhome
和admin
是具有自己路由的模块,并放置在libs
. 当我运行我的应用程序时,我的模块没有被加载。我想这只是一个路径问题..有人可以指导我如何从 nrwl 工作区的库文件夹中正确配置延迟加载模块吗?
这是我得到的错误:
ERROR Error: Uncaught (in promise): Error: Cannot find module 'libs/home/home.module'.
Error: Cannot find module 'libs/home/home.module'.
at eval (eval at ../../../../../apps/myapp/src/$$_lazy_route_resource lazy recursive (main.bundle.js:6), <anonymous>:5:9)
at ZoneDelegate.invoke (webpack-internal:///../../../../zone.js/dist/zone.js:388)
注意:我更新了我的 tsconfig.app.json 和 tslint.json 如下:tslint.json
"nx-enforce-module-boundaries": [
true,
{
"lazyLoad": [
"home",
"admin"
],
"allow": []
}
]
和 tsconfig.app.json:
"include": [
"**/*.ts",
/* add all lazy-loaded libraries here: "../../../libs/my-lib/index.ts" */
"../../../libs/home/index.ts",
"../../../libs/admin/index.ts"
],
谢谢。