I know this has been asked in different forms here and also in the angular-cli github, but I couldn't find any helpful answer (and @ngtools/webpack documentation isn't quite complete).
To put it simple, I wanted to test AoT with a fresh app created from angular-cli and using it outside angular-cli, so the steps were:
ng new test-app
ng eject
- Minor modifications to the two files involved:
webpack.config.js
was modified to include an entryModulemain.ts
was modified to bootstrap a compiled factory module instead of a standard module
I have also deleted the .ngfactory files created when the app is ejected, just to make a fresh clean start.
What happens when I run Webpack? (omitted absolute path details with [...])
ERROR in [...]/test-app/src/main.ts (4,36): Cannot find module './app/app.module.ngfactory'.
ERROR in ./src/main.ts
Module not found: Error: Can't resolve './app/app.module.ngfactory' in '[...]/test-app/src'
But if I previously run the ngc manually, everything works fine, obviously because app.module.ngfactory
was generated.
The thing is, it is stated that @ngtools/webpack keeps the generated .ngfactory files in memory and then everything is bundled in the webpack output, makes sense. But I have no idea why it can't find this "in memory" .ngfactory files, and I can't find any way to debug if the paths are not correct or anything else.
Yes, I know that I can build first with ngc and then use Webpack, but that kind of ruins the whole thing about the AoT plugin.
This is the main.ts: https://github.com/JimGV/angularaot/blob/master/src/main.ts
This is the webpack config: https://github.com/JimGV/angularaot/blob/master/webpack.config.js
This is just the plugin config part:
new AotPlugin({
"hostReplacementPaths": {
"environments/environment.ts": "environments/environment.ts"
},
"entryModule": __dirname + "/src/app/app.module#AppModule",
"exclude": [],
"tsConfigPath": __dirname + "/src/tsconfig.app.json",
"skipCodeGeneration": true
})
I'm on a Mac El Capitan, running node 8.1.1 and Angular 4.2.4 and @ngtools/webpack 1.4.1
Thanks in advance