If a single file is handled incorrectly OR not loaded at all, you'll get an infinite loop on 95% emitting.
UPDATE::
It appears that there is one area where errors will get swallowed up:
reject(new Error('Child compilation failed:\n' + errorDetails));
That is line 57 of @ngtools\webpack\src\resource_loader.js
You'll want to put a breakpoint to debug or output that error details, or you'll be stuck on AOT compiling forever.
Just going to leave this in case someone is stuck in the future, basically if you get stuck in an infinite loop you're probably on the right track..
I finally have something working, there were so many issues along the way..
The main thing that bit me that I didn't understand is, I guess, that for AoT, ALL YOUR FILES have to be loaded into webpack
This is the module.rules config that finally got me running...
// Ahead of Time Compilation
[{ test: /\.ts$/, loader: '@ngtools/webpack', exclude: [/\.(spec)\.ts$/] },
// AoT requires all files to be loaded
{ test: /\.html$/, loader: 'html-loader' },
{ test: /\.css$/, loader: 'raw-loader' },
{
test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico)$/,
loader: 'file-loader', options: { name: '[path][name].[ext]' }
}]
I added this loader which basically just puts my images back into the exact same place they exist.. But I guess that causes them to be packaged correctly..
If I do not include a file type (or if there is some sort of error while loading a file see comment below) then I get caught in an infinite loop...
If you run webpack with --progress --profile you will see that it gets stuck on 95% emitting.
What's going on behind the scenes is some sort of absolute path vs relative path issue and it gets caught in a loop in mkdirp.
But I guess the trick is for AoT, is to just make sure that you have a loader for EVERY file type that you are using.