angular production compilation: function call is not supported in decorates but PublicClientApplication was called

Tarek, Taher 90 Reputation points
2023-06-25T17:23:11.17+00:00

after enabling azure AD auth in my SPA app using MSAL. everything works perfectly on dev env but while using ng build --prod i get error "error during template compile of 'AppModule' function calls are not supported in decorators but 'PublicClientApplication' was called." app.module.ts as following

imports..

@NgModule({

  declarations: [
  ],
  imports: [
    ..,
    MsalModule.forRoot(new PublicClientApplication(
      {
        auth: {
          clientId: environment.clientId,
          authority: environment.authority,
          redirectUri: environment.redirectUri,
          postLogoutRedirectUri: environment.postLogoutRedirectUri

        },
        cache: {
          cacheLocation: "localStorage",
          storeAuthStateInCookie: isIE, //declared const
        },
      }),
      {
      interactionType: InteractionType.Redirect,
      authRequest: {
        scopes: ['User.ReadWrite']
      }
      },
      {
      interactionType: InteractionType.Redirect, // MSAL Interceptor Configuration
      protectedResourceMap: new Map([
        ['https://graph.microsoft.com/v1.0/', ['User.read']]
      ])
    }),
  ],
  exports: [],
  providers: []

})
export class AppModule { }


Microsoft Security | Microsoft Entra | Microsoft Entra ID
{count} vote

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.