googlemaps/v3-utility-library

SCRIPT1053: Const must be initialized - IE11 issue

madebyakash456 opened this issue · 9 comments

Environment Details

  1. MarkerClustererPlus library within an Angular App
  2. On Windows IE11 browser
  3. Library Version: 5.0.3

The error traces back to the OverlayViewSafe class - extend function.
function extend(type1, type2) {
for (const property in type2.prototype) {
type1.prototype[property] = type2.prototype[property];
}
}

You likely need to modify your Babel settings for the angular app. The const is only distributed in the es module format and not in the iife or umd outputs.

@jpoehnelt How can this be done? I'm running into the same problem.

How are you building your app? webpack, rollup?

How are you building your app? webpack, rollup?

Angular 9 using the CLI, so there is no ejected Webpack configuration.

@jpoehnelt The new release does not fix compatibility with IE11, since the package still uses classes, which are not supported in ES5. I think transpiling the code to ES5 will be the only solution here.

Can you share your tsconfig?

target
By default, the target is es2015, which is supported only in modern browsers. You can configure the target to es5 to specifically support legacy browsers. Differential loading is also provided by the Angular CLI to support modern, and legacy browsers with separate bundles.

https://angular.io/guide/typescript-configuration#target

You likely need to adjust the target for tsconfig to fully support ie11. I believe that the default is ES2015(ES6) for angular right now.

My target is set to es5, that is not the problem. The usage of classes in the library gives the error, since the library is not affected by the TypeScript target.

TSConfig:

{
  "compileOnSave": false,
  "compilerOptions": {
    "downlevelIteration": true,
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2017",
      "dom",
      "esnext"
    ],
    "module": "es2015",
    "baseUrl": "./"
  }
}

The usage of classes in the library gives the error, since the library is not affected by the TypeScript target.

At this point, I would suggest asking this on StackOverflow or similar. Please post back here with the question and your answer.