Daniel Hilgarth
Daniel Hilgarth

Reputation: 174279

Trouble shoot "Runtime compiler is not loaded"

I am getting the following runtime error after building my Angular2 app with the --prod flag:

Runtime compiler is not loaded

I understand that the production builds use AoT and that runtime compiling isn't supported in this scenario.
My problem is: I am not aware of anything I am doing that would need the runtime compiler. It might even be an external component I am using.

How do I find out what component is causing this error?

Upvotes: 4

Views: 1646

Answers (1)

SirWojtek
SirWojtek

Reputation: 348

I have had the similar issue with AoT compilation when I was trying to use lazy module loading using module type instead of the path.

Correct loading:

{ path: 'lazy', loadChildren: 'lazy/lazy.module#LazyModule' }

Way, I've done it (crashes AoT):

export function loadLazyModule() {
  return LazyModule;
}
export const appRoutes: Routes = [
  { path: 'lazy', loadChildren: loadLazyModule, },
];

Indeed the error message is not helpful at all, however, the stack trace is:

at Compiler.compileModuleAsync (core.js:3664)
at MergeMapSubscriber.eval [as project] (router.js:4467)

I've just made a breakpoint at compileModuleAsync function and at the stop I saw the module which was causing the error.

Upvotes: 1

Related Questions