I'm not using Angular CLI for my AOT builds, and am using Angular 4.x. I have created a module which I intend to load as a lazily loaded module. Here is the file project partial structure:
- app
|----lazyLoadedModuleFolder
| |
| --- componentsFolder
| --- lazyload.module.ts
|
|-----main.aot.ts
In my main.aot.ts file, which is used for my AOT builds, I have:
import { MyAppLicationModuleNgFactory } from './../aot/src/MyApplicationModule.module.ngfactory';
import { enableProdMode } from '@angular/core';
import { platformBrowser } from '@angular/platform-browser';
if (webpack.ENV === 'production') {
enableProdMode();
}
platformBrowser().bootstrapModuleFactory( MyAppLicationModuleNgFactory);
In my routing configuration I have the following for the lazily loaded module:
const appRoutes: Routes = [
...
{ path: 'myapp/lazyLoadView', loadChildren: './app/lazyLoadedModuleFolder/lazyload.module'}
];
In my lazyload.module.ts file I'm exporting the following class:
export default class lazyLoadModule {
}
When I run the JIT build, everything works fine, however, when I run the AOT build, I get the following error:
Can't resolve '.\app\lazyLoadedModuleFolder\lazyload.module'
If I don't use lazy loading (converting the module to an eagerly loaded module), everything works fine.
Here is my tsconfig.aot.json which is used for aot builds:
{
"compilerOptions": {
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"noEmit": true,
"module": "es2015",
"sourceMap": true,
"target": "es5",
"types": ["es6-shim", "jasmine"],
"noImplicitAny": true,
"allowJs": true,
"removeComments": false,
"suppressImplicitAnyIndexErrors": true,
"moduleResolution": "node",
"lib": ["es2015", "es2015.iterable", "dom"],
"skipLibCheck": true
},
"files": [
"src/main.ts",
"src/main.aot.ts",
"src/app/lazyLoadedModuleFolder/lazyload.module.ts",
"src/typings.d.ts"
],
"angularCompilerOptions": {
"genDir": "aot",
"skipMetadataEmit": true
}
}
Also, I am using the following loader in my webpack.config file for my AOT builds:
{ loader: 'angular2-template-loader' }
So I'm wondering why my AOT build does not work when I'm using lazy loading, but works just fine when I'm not using the module as a lazy loaded module.
Thank you in advance for your help.