0

I've been researching and searching for days about this problem, but haven't been able to find a solution although various variants have been posted online.

When I try to compile my application with the Angular CLI in production mode, I get the following error:

Error encountered resolving symbol values statically. Calling function 'FluffySpoonAuthenticationModule', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol AppModule in app.module.ts, resolving symbol AppModule in app.module.ts

Here's the relevant parts of app.module.ts.

import { FluffySpoonAuthenticationModule } from '@fluffy-spoon/angular.authentication.jwt';

@NgModule({
  imports: [
    FluffySpoonAuthenticationModule.forRoot('foo')
  ]
})
export class AppModule {}

Now, obviously in the imports section, I am calling a method. But since I need to specify a dynamic string value as part of the module, I need to be able to somehow call a method for configuring that part. Besides, why would it work with other forRoot calls and not mine, right?

The source codes for FluffySpoonAuthenticationModule are here: https://github.com/ffMathy/FluffySpoon.Angular.Authentication.Jwt/

I am using the command ionic cordova build android --prod

Mathias Lykkegaard Lorenzen
  • 15,031
  • 23
  • 100
  • 187
  • Don't quote me on that but I think forRoot was deprecated a long time ago. There is a way to pass values as providers but I don't remember what it is. – Ploppy Jul 02 '18 at 14:39
  • Well you can use `providers: [{provide: , useValue: someValue}]`, however, in this case, as seen in the FluffySpoon source codes, I want to have the provided service as a Singleton. How to get that working here? – Mathias Lykkegaard Lorenzen Jul 02 '18 at 14:47
  • I tried out your project using Angular CLI 6.0.3 and got only warning, no errors. I don't see anything wrong about it actually. If you just copy your source to fresh new Angular CLI project and import it to the root module, are you still able to reproduce it? – Dan Macak Jul 02 '18 at 17:37
  • Did you run it with the - - prod and aot command line argument? It doesn't throw an error without it. – Mathias Lykkegaard Lorenzen Jul 02 '18 at 18:13
  • Yes I did, only warnings occured. Btw don't forget to mention me in the comment so that I get notified :). – Dan Macak Jul 02 '18 at 19:24
  • Hmmm! I just realized this is not Angular 6, but Angular 5 because it is an Ionic application. – Mathias Lykkegaard Lorenzen Jul 03 '18 at 05:38
  • @DanMacák I updated the question with more details (tagged with versions). – Mathias Lykkegaard Lorenzen Jul 03 '18 at 06:25
  • I tried it again with angular@5.2.11 and still no difference, just warnings. What is your exact version? The only potential problem I see is in FluffySpoonAuthenticationModule with those if conditions in factory functions, try to return always a new instance there unconditionally and let me know if that helps. – Dan Macak Jul 03 '18 at 18:43

0 Answers0