Angular AOT using isDevMode giving error

Viewed 325

When using isDevMode() working fine for JIT build, while failed for AOT stating

Error: Error encountered resolving symbol values statically. Calling function 'isDevMode', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function

trying to create export function like this but no luck

export function isDevModeEnabled() {
   return isDevMode();
}
2 Answers

So I also encountered this error, and raised it as an issue here. The official response from the Angular 2 development team is that this is not a bug:

I believe this is an intended behaviour. The solution is to move isDevMode() out of the annotation. (By defining to a variable)

The official solution is:

[...] You will need to set the return value to a variable, and use the variable rather than calling the function when wiring up the NgModule.

A wild guess, but maybe you can try to make the function public instead of anything esle - it helped me with problems when I tried AOT compile.

Related