Angular2-jwt: AOT does not compile still.

Created on 28 Oct 2016  路  7Comments  路  Source: auth0/angular2-jwt

I updated to latest package, but AOT still does not compile using current npm version 0.1.25. I do not see the .ts files, but I receive error from ngc

Error: Error at C:/Source/master/aot-compiled/src/app-components/app/app.module.ngfactory.ts:151:32: 
Module '"C:/Source/master/node_modules/angular2-jwt/angular2-jwt"' has no exported member 'AUTH_PROVIDERS'.

Error at C:/master/aot-compiled/src/app-components/app/app.module.ngfactory.ts:409:37: 
Module '"C:/Source/master/node_modules/angular2-jwt/angular2-jwt"' has no exported member 'AUTH_PROVIDERS'.

which I don't understand, because I see that angular2-jwt.js does indeed have the exported member:

exports.AUTH_PROVIDERS = [
    {
        provide: AuthHttp,
        deps: [http_1.Http, http_1.RequestOptions],
        useFactory: function (http, options) {
            return new AuthHttp(new AuthConfig(), http, options);
        }
    }
];

Most helpful comment

I'm also having this problem. Is there any updates for this?

All 7 comments

I used @manduro's suggestion here https://github.com/auth0/angular2-jwt/issues/158 and that works, which means not importing AUTH_PROVIDERS from angular2-jwt, and basically recreating it inside the app.bootstrap file. Is there any plan to fix this so we don't have to workaround it?

This is the workaround

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 AUTH_PROVIDERS = {
   provide: AuthHttp,
   deps: [Http, RequestOptions],
   useFactory: authFactory
};

I'm also having this problem. Is there any updates for this?

@IAMtheIAM
Thanks, It is a very easy change, I hope it is added soon.

I thought I added it a while ago, but apparently I did not.

duplicates #158. If this is in error, please reopen.

@escardin still having this with 0,1,27

Still not working in 0.1.28 as well.

ERROR in Error encountered resolving symbol values statically. Only initialized variables and constants can be referenced because the value of this variable is needed by the template compiler (position 79:22 in the original .ts file), resolving symbol AUTH_PROVIDERS

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tekkudoc picture tekkudoc  路  5Comments

guillaume-skwid picture guillaume-skwid  路  5Comments

sfabriece picture sfabriece  路  4Comments

n0490b picture n0490b  路  4Comments

UlyssesAlves picture UlyssesAlves  路  5Comments