Reputation: 1461
My app runs fine with a dev build, but I'm not getting the AOT production build to work. For each lazy loaded module, I get an error like this:
ERROR in ./target/aot/src/main/webapp/app/app.module.ngfactory.ts
Module not found: Error: Can't resolve './features/about/about.module.ngfactory' in '/Users/Dan/work/a/gba/target/aot/src/main/webapp/app'
@ ./target/aot/src/main/webapp/app/app.module.ngfactory.ts 535:190-240
@ ./src/main/webapp/app/app.main-aot.ts
and one like this:
ERROR in ./src/main/webapp/app/app.routing.ts
Module not found: Error: Can't resolve '../../../../target/aot/src/main/webapp/app/features/about/about.module.ngfactory' in '/Users/Dan/work/a/gba/src/main/webapp/app'
@ ./src/main/webapp/app/app.routing.ts 15:137-228
@ ./target/aot/src/main/webapp/app/app.module.ngfactory.ts
@ ./src/main/webapp/app/app.main-aot.ts
The paths seems correct but the files for these modules are not there. If I make a lazy loaded module load eagerly, then the error for that one goes away.
I followed the directions from angular-router-loader. I think I did it right but no luck
// webpack.prod.js
{ loader: 'angular-router-loader?aot=true&genDir=target/aot' }
// tsconfig-aot.json
"angularCompilerOptions": {
"genDir": "target/aot",
"skipMetadataEmit": true
}
Upvotes: 0
Views: 718
Reputation: 214077
I suspect your issue is related with your tsconfig-aot.json
since angular's compiler looks the files you've handed to tsconfig.
So here is my assumption:
tsconfig-aot.json
"files": [
"src/main/webapp/app/app.module.ts",
"src/main/webapp/app/app.main-aot.ts",
"src/main/webpapp/app/features/about/about.module.ts" <= try to add this
],
Upvotes: 2