Everything just works fine in JiT compilcation but I get the following compilation error when I try to compile with AoT. Can anyone explain what is going on?
I´m using auth0-lock v.10.4.0 and angular2-jwt v.0.1.24
Error:
Module '".../node_modules/angular2-jwt/angular2-jwt"' has no exported member 'AUTH_PROVIDERS'.
I´m using lazy loading so I have a shared module for the AuthService and AUTH_PROVIDER like so:
import { AuthService } from '../common/auth.service';
import { AUTH_PROVIDERS } from 'angular2-jwt';
@NgModule({
imports: [CommonModule],
declarations: [],
exports: []
})
export class SharedModule {
static forRoot(): ModuleWithProviders {
return {
ngModule: SharedModule,
providers: [
AuthService,
AUTH_PROVIDERS]
};
}
}
Found a solution here https://github.com/auth0/angular2-jwt/issues/158
Instead of AUTH_PROVIDER create your own provider like so:
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
};