I know that we can use lazy loading by specifying path to module:
const routes: Routes = [
{path: '', component: AdminComponent, children: [
{path: 'app', loadChildren: './app/app.module#AppModule' },
{path: 'anotherPath', component: SomeComponent }
]},
];
Is there possibility to define lazyloaded module as?:
import {AppModule} from 'somePath';
const routes: Routes = [
{path: '', component: AdminComponent, children: [
{path: 'app', loadChildren: AppModule },
{path: 'anotherPath', component: SomeComponent }
]},
];
The reason why I am asking about that is:
I want to keep my child modules in different git repos, and install them as dependencies of main project. Thats requires from me to specify path to module as follows:
{path: 'moduleA', loadChildren: '../node_modules/my-module-A/some_other_path/app/app.module#AppModule' },
This already looks a little bit weird for me.
Now imagine situation, that moduleA
have another dependency, let's say moduleAB
. So here, again developer is specifieng path to module as ../node_modules/etc
When we isntall moduleA in our main application, we got following catalog structure:
- application_code/
|
- node_modules/
|
- moduleA/
| |
| - src/module_code_goes_here
|
- moduleAB/
|
- src/module_code_goes_here
And now the problem starts. ModuleA is loaded properly, but for ModuleAB angular is trying to look for in catalog node_modules/moduleA/node_modules/moduleAB
instead of node_modules/moduleAB
.
So if you want to develop big app, built from seperated modules which could depend on other modules, big disaster is coming...