Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MsalModule.forRoot throws AoT error #386

Closed
ghost opened this issue Aug 9, 2018 · 8 comments
Closed

MsalModule.forRoot throws AoT error #386

ghost opened this issue Aug 9, 2018 · 8 comments
Assignees
Labels
bug A problem that needs to be fixed for the feature to function as intended.

Comments

@ghost
Copy link

ghost commented Aug 9, 2018

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Other... Please describe:

Current behavior

The MsalModule.forRoot function throws an AoT error when compiling with v6.1.
It may have to do with the use of the window object. The compiler throws error: Error: Internal error: unknown identifier undefined

Expected behavior

I expect AoT compilation to work, regardless of version. If it is because of the Window interface being used as an injection token, a fix is described here: angular/angular#12631 (comment)

Minimal reproduction of the problem with instructions

Import MsalModule with any forRoot configuration and compile with Angular compiler > v6 and use --aot flag.

@ghost ghost changed the title Window provider in msal-angular MsalModule throws AoT error MsalModule.forRoot throws AoT error Aug 9, 2018
@nehaagrawal nehaagrawal self-assigned this Aug 9, 2018
@nehaagrawal
Copy link
Contributor

@sharppc Thanks for reporting this. I will be doing another release in this week.

@RobARichardson
Copy link

Having the same issue. If I remove the MsalModule from my app, the AOT compilation error goes away.

@nehaagrawal nehaagrawal added the bug A problem that needs to be fixed for the feature to function as intended. label Aug 14, 2018
@nehaagrawal
Copy link
Contributor

@RobARichardson @sharppc This is fixed and released in @azure/msal-angular 0.1.1 . Please check.

@RobARichardson
Copy link

Thanks, @nehaagrawal. Compilation error is gone, but I'm now seeing this warning in its place

WARNING in ./src/app/app.module.ngfactory.js
85:19195-19212 "export 'WindowWrapper' (imported as 'i52') was not found in '@azure/msal-angular/dist/msal.module'

Furthermore, while I'm not 100% certain this is related, when my app is compiled for production, Msal no longer appears to be adding the Authorization Token to the Http Request Headers therefore all XHR requests are getting a 401 Unauthorized.

@nehaagrawal
Copy link
Contributor

@RobARichardson This is working fine. Can you please try our sample here and run "ng build --prod --aot". I was able to the token and it was added in the header.

@RobARichardson
Copy link

@nehaagrawal I pulled down the sample and tried it. When I run the app using "ng serve", everything works normally. However, when I run the app using "ng serve --prod --aot", I'm seeing the same behavior as my own app: the requests to graph.microsoft.com/v1.0/me are missing the Authorization header and fail due to a 401 Unauthorized.

@nehaagrawal
Copy link
Contributor

@RobARichardson Sorry I didn't get earlier that you were running "ng serve --prod --aot" instead of "ng serve". I was trying to build it using aot using "ng build --prod --aot" and then run it using "ng serve" and hence I couldn't reproduce it. I can reproduce it now. I will fix it and release it soon. Thanks for reporting this.

@nehaagrawal
Copy link
Contributor

@RobARichardson This is fixed and released in msal-angular 0.1.2. You will need to change the way you pass the protectedResourceMap. Please check readme for more details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A problem that needs to be fixed for the feature to function as intended.
Projects
None yet
Development

No branches or pull requests

2 participants