I am trying to convert an App that was already working with Lazy loaded modules into AOT. I am using the @ngtools/webpack toolkit to compile the AOT code, however I am getting into an error that Angular cant find the Lazy loaded module's code as it seems.
ERROR in ./src/ngfactory async Module not found: Error: Can't resolve '/Library/WebServer/Documents/envato-teams/src/ngfactory/src/app/components/container/projects.ngfactory.ts' in '/Library/WebServer/Documents/envato-teams/src/ngfactory' @ ./src/ngfactory async @ ./~/@angular/core/src/linker/system_js_ng_module_factory_loader.js @ ./src/ngfactory/src/app/app.module.ngfactory.ts @ ./src/main.aot.ts @ multi main
Worth mention in my app routes definition this project's module is loaded lazily :
{ path: 'projects', loadChildren: './components/container/projects#ProjectModule' },
This is how my setup looks like:
tsconfig :
... "angularCompilerOptions": { "genDir": "./src/ngfactory", "entryModule": "src/app/app.module#AppModule" } ...
Webpack :
new ngtools.AotPlugin({ tsConfigPath: './tsconfig.aot.json', }),
Main.aot.ts
/* * Providers provided by Angular */ import { platformBrowser } from '@angular/platform-browser'; import { AppModuleNgFactory } from './ngfactory/src/app/app.module.ngfactory'; import { Servicesconfig } from './app/services/index'; platformBrowser().bootstrapModuleFactory(AppModuleNgFactory);
In webpack I am compiling ts files with @ngtools/Webpack by doing :
// Support for .ts files. { test: /\.ts$/, loaders: ['@ngtools/webpack'], exclude: [/\.(spec|e2e)\.ts$/] },
Thank you for your help!