Issue with assigning object properties in Internet Explorer 11 with ECMAScript

I recently made some changes to my Angular7 app, including an upgrade to Angular7 and upgrading package dependencies. However, I encountered an issue when testing my app on PROD Internet Explorer 11. While there are no problems when testing on localhost, once the app is deployed to PROD, I receive the following error:

SCRIPT1003: Expected ':'
main-client.js (559,109)

Upon investigating the main-client.js file, I found the following line causing the error:

Pr={"ɵdefineBase":defineBase,
"ɵdefineComponent":defineComponent,
"ɵdefineDirective":H,
defineInjectable, ## This is line:559 and column:109 ##

The issue lies with the line defineInjectable, which should be

"defineInjectable": defineInjectable
. I tested the correction in the IE11 developer tools with the following example:

c = 3; d=4; values = {a:1, b:2, c, d} output is: Expected ':'

However, IE11 expects it to be written as:

c = 3; d=4; values = {a:1, b:2, c:c, d:d} outpus is: OK

It is possible that the issue is related to the ECMAScript version or Webpack settings as I use webpack for building the application. I have not been able to pinpoint the exact cause. If needed, I can provide my webpack.config files. Here are my tsconfig files:

tsconfig.json

    {
  "compilerOptions": {
    "moduleResolution": "node",
    "module": "es2015",
    "target": "es5",
    "alwaysStrict": true,
    "noImplicitAny": false,
    "sourceMap": true,
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "skipDefaultLibCheck": true,
    "skipLibCheck": true,
    "allowUnreachableCode": false,
    "lib": [
      "es2016",
      "dom"
    ],
    "types": [ "node" ]
  },
  "include": [
    "ClientApp"
  ]
}

tsconfig.app.json

    {
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/app",
    "module": "es2015",
    "baseUrl": "",
    "sourceMap": true,
    "types": ["node"]
  },
  "exclude": [
    "test.ts", 
    "**/*.spec.ts"
  ]
}

tsconfig.spec.json

    {
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/spec",
    "module": "commonjs",
    "target": "es5",
    "baseUrl": "",
    "types": ["jasmine", "node"]
  },
  "files": ["polyfills.ts"],
  "include": ["**/*.spec.ts", "**/*.d.ts"]
}

Answer №1

The issue was resolved by making changes to the webpack configuration files, specifically webpack.config.js and webpack.config.vendor.js, utilizing the TerserPlugin as an alternative to UglifyJsPlugin. It is important to note that the plugin options must be updated in both files for the solution to be effective.

Within webpack.config.js and webpack.config.vendor.js

    new TerserPlugin({ //or UglifyJsPlugin
      cache: true,
      parallel: true,
      terserOptions: {
        compress: false,
        ecma: 6, //Changing this to "ecma: 5" resolved the issue.
        mangle: true,
        keep_classnames: true,
        keep_fnames: true
      },
      sourceMap: true
    })

The solution was discovered through the following sources:

This solution should be beneficial for others facing similar issues.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Utilizing a directive for dynamically applying classes to the host element

Exploring the world of Angular 2 has been quite interesting. I recently grasped the concept of using the Angular Renderer to manipulate ElementStyle, and now I am eager to dive into the Renderer method: setElementClass(renderElement: any, className: strin ...

Create an array variable for services in Angular

My goal is to define this user as an array. users = new BehaviorSubject<any>([]); In my component, I am attempting to add the userID to the array. this.Service.users.push(userID); To subscribe to it, I use the following code: this.Service.users.su ...

Having trouble getting two separate static directories (Angular apps in the "dist" folder) to work in a Node.js Express framework setup?

I have encountered an issue with setting up my two Angular apps and a single Node app. Both Angular apps consume APIs from the Node app, and I am trying to configure these client apps using NodeJs. Although I wrote the following code, it is not functioning ...

Refreshing the PrimeNg Organization Chart through code executionPrimeNg Organization Chart

Using the p-organizationChart to display hierarchy, I encounter an issue where dynamically added child nodes do not display the expand arrow until I select a Node. Therefore, I am seeking a way to programmatically refresh the org-chart. Any suggestions on ...

Executing a Playwright test against various projects or URLs within a single test run

I've been grappling with this problem for the past few days. I've tried a few workarounds, but none of them have worked as expected. What I need is to run Playwright tests against multiple URLs. Currently, running tests in a single project works ...

After transpiling the package with babel in a new CRA, I noticed that the CSS and image files are not

element lies my inquiry about the process of importing CSS files and images in a React project. Specifically, I aim to create a package, share it on npm without going through the building phase, and then integrate it into a new Create React App (CRA) for ...

How can I retrieve the current table instance in NGX-Datatables?

I have a component that includes a table. This table receives RowData from another component through the use of @Input. How can I access the current instance of this table? Here is a snippet of my HTML: <ngx-datatable class="material" ...

Transferring client-side data through server functions in Next.js version 14

I am working on a sample Next.js application that includes a form for submitting usernames to the server using server actions. In addition to the username, I also need to send the timestamp of the form submission. To achieve this, I set up a hidden input f ...

Converting JSON HTTP response to an Array in AngularJS 2: A Comprehensive Guide

As I work on a Http get request in Angular 2, the response returned is in JSON format. However, I am facing an issue when trying to use it in a ngFor loop because it is not formatted as an Array. Is there a way to convert JSON data to an Array in Angular ...

The IE browser is showing a blank page when I try to open my Angular 8 application

Even after incorporating all the necessary polyfills and making updates to the browserlist file and tsconfig file, I am still unable to identify a solution. Any assistance would be greatly appreciated. ...

Creating a custom pipe that converts seconds to hours and minutes retrieved from an API can be achieved by implementing a transformation function

Can someone please provide guidance on creating a custom pipe in Angular 8 that converts seconds to hours and minutes? Thank you. <div class="col-2" *ngFor="let movie of moviesList"> <div class="movie"> {{ movie.attributes.title }} ...

Using TypeScript to create a generic function that returns a null value

In my Typescript code, I have the following function: In C#, you can use default(T), but I'm not sure what the equivalent is in Typescript. public Base { ... } public Get<T extends Base>(cultura: string): T[] { let res = null; try ...

Is there a way to detect and handle errors triggered by a callback function?

My component has the following code snippet: this.loginService.login(this.user, () => { this.router.navigateByUrl('/'); }); Additionally, my service contains this method: login(credentials, callback) { co ...

Angular4 allows for the creation of a div that can horizontally scroll

Below is the HTML code I am working with: <div class="card-deck" fxLayout.xs="row" style="overflow: scroll; height:100%"> <md-card style="width:10rem" *ngFor="let make of filteredMakes" (click)="goToModels(make.niceName)" class=" ...

Encountering a MODULE_NOT_FOUND error while trying to execute "npm run build"

I have encountered an issue while trying to deploy my application on my GoDaddy server. Upon running 'npm run build,' I am receiving the following error message: PS C:\Users\trump\Documents\Rider Project\PreChiS-E---Stud ...

Bug in auto compilation in Typescript within the Visual Studios 2015

Currently, I am utilizing Visual Studio Pro 2015 with auto compile enabled on save feature. The issue arises in the compiled js file when an error occurs within the typescript __extends function. Specifically, it states 'Cannot read property prototyp ...

typescript add an html element to an existing html document

I'm experimenting with creating a dynamic HTML element using TypeScript to display on a webpage. In my .ts file, my code looks like this: const displayContent = document.getElementById("display-content") as HTMLOutputElement; var displayVariable = " ...

Issue with Vue3: The imported module is not defined

Update: I recently downgraded vue-cli to version 4.5.19 and now the code is functioning properly. It seems like there might be an issue related to vue-cli or its dependencies. I encountered a problem while working on a simple vue.js project using vue-cli. ...

Troubleshooting engine malfunction in Angular 9 caused by FormGroup usage

Here is a sample code snippet of a component: export class BaseFormComponent implements OnInit { basicFormGroup: FormGroup; constructor( protected basicProviderService: BasicProviderService, protected formBuilder: FormBuilder, protected di ...

Docker brings up the login page, yet the node server.js for the MEAN stack isn't launching

Here's the latest configuration updates after adding a bounty: Configuration UPDATE: It seems that there is a CORS error occurring when trying to login, which is likely causing the problem. I've come across other posts, like this one, suggesting ...