Angular2-jwt: RC6: Error when compiling Ahead-Of-Time + provideAuth()

Created on 11 Sep 2016  ·  5Comments  ·  Source: auth0/angular2-jwt

Running the app with JIT (ng serve) works perfectly, but when trying out AOT it failts with this error message:

./node_modules/.bin/ngc -p ./src Error: Error encountered resolving symbol values statically. Calling function 'provideAuth', function calls are not supported. Consider replacing the function or lambda wi th a reference to an exported function, resolving symbol AppModule in ......./app.module.ts

stale enhancement has pull request

Most helpful comment

I'm using this with AOT:

export function authFactory(http: Http, options: RequestOptions) {
  return new AuthHttp(new AuthConfig({
    // Config options if you want
  }), http, options);
};

// Include this in your ngModule providers
export const authProvider = {
  provide: AuthHttp,
  deps: [Http, RequestOptions],
  useFactory: authFactory
};

All 5 comments

I have the same problem with exported member AUTH_PROVIDERS.
Any news on this? Is there any workaround?

Yes, you cannot use AOT with this library, maybe you'll need to do a JWTModule?

I'm using this with AOT:

export function authFactory(http: Http, options: RequestOptions) {
  return new AuthHttp(new AuthConfig({
    // Config options if you want
  }), http, options);
};

// Include this in your ngModule providers
export const authProvider = {
  provide: AuthHttp,
  deps: [Http, RequestOptions],
  useFactory: authFactory
};

@Manduro That fixed it dude, thanks a ton.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you have not received a response for our team (apologies for the delay) and this is still a blocker, please reply with additional information or just a ping. Thank you for your contribution! 🙇‍♂️

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jaumard picture jaumard  ·  5Comments

dmitrybz picture dmitrybz  ·  4Comments

Betalos picture Betalos  ·  5Comments

Eddman picture Eddman  ·  3Comments

huineng picture huineng  ·  4Comments