Fixing Syntax Error in Internet Explorer 11 + Angular 6+ project

Viewed 3910

I'm using the msal.js "@azure/msal-angular": "^0.1.2" in both Angular 6 and Angular 7 projects and I get the following error:

SCRIPT1002: Syntax error
vendor.js (64379,1)

The .js code on line 64379

class AuthenticationResult {
constructor(token, tokenType) {
    this._token = "";
    this._tokenType = "";
    this._token = token;
    if (tokenType) {
        this._tokenType = tokenType;
    }
}
get token() {
    return this._token;
}
set token(value) {
    this._token = value;
}
get tokenType() {
    return this._tokenType;
}
set tokenType(value) {
    this._tokenType = value;
}}

I added rxjs-compat npm module to support Angular 6+.

Tried the following fix for IE 11:

uncommented polyfills.ts

<meta http-equiv="X-UA-Compatible" content="IE=edge" />

https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/Using-msal.js-with-Internet-Explorer

4 Answers

This fix is currently working for me.

Problem: The dist folder(@azure\msal-angular\dist) in NPM package @azure/msal-angular is compiled incorrectly for IE11.

Fix: Recompile the ts files (https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/lib/msal-angular) and add to your projects node_modules\@azure\msal-angular\dist

Steps

  1. clone and npm install https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/lib/msal-angular
  2. npm run build:modules
  3. copy the newly created files from lib-es6
  4. paste lib-es6 files to your angular projects node_modules\@azure\msal-angular\dist

npm start your angular project.

there is an msal npm package that works basically the same. Im using that in my angular 7 app.

As per the document of this library. this is only supported in Angular(4.3-5). Didn't support Angular 6 or 7. You need to wait for a release that will support Angular 7.

Ref :- https://www.npmjs.com/package/@azure/msal-angular

The MSAL library preview for Angular is a wrapper of the core MSAL.js library which enables Angular(4.3 to 5) applications to authenticate enterprise users using Microsoft Azure Active Directory (AAD), Microsoft account users (MSA), users using social identity providers like Facebook, Google, LinkedIn etc. and get access to Microsoft Cloud OR Microsoft Graph.

Related