DEV Community

Cover image for Solution for Angular IE Error: Uncaught (in promise) Loading chunk
Sandip Malaviya for Samarpan Infotech

Posted on • Updated on • Originally published at samarpaninfotech.com

Solution for Angular IE Error: Uncaught (in promise) Loading chunk

In this article, angular developer will learn the most common error's solution which is: "Uncaught (in promise) Loading chunk" Angular & IE. Developer is facing this error while working with angular and IE browser, Yes App is running fine with chrome & another browser but not in internet explorer.

#2 Step to solve Internet explorer & Angular Error: Uncaught (in promise): Loading chunk

After researching some hours; we finally found solution and that issue about promise((t,n)=>, promise keyword does not supporting in IE.

STEP 1: Open the src/polyfills.ts file, and uncomment below code

/** IE9, IE10 and IE11 requires all of the following polyfills. **/
// import 'core-js/es6/symbol';
// import 'core-js/es6/object';
// import 'core-js/es6/function';
// import 'core-js/es6/parse-int';
// import 'core-js/es6/parse-float';
// import 'core-js/es6/number';
// import 'core-js/es6/math';
// import 'core-js/es6/string';
// import 'core-js/es6/date';
// import 'core-js/es6/array';
// import 'core-js/es6/regexp';
// import 'core-js/es6/map';
// import 'core-js/es6/weak-map';
// import 'core-js/es6/set';
  • lambda expression does not support in IE so we can replace with code function() instead of this expression.

STEP 2: Install some packages as below

npm install --save web-animations-js
npm install --save classlist.js
  • Then We found promise issue from one of the npm package (fuctbase64/index.js)
module.exports = function (event) {
  return new Promise((resolve, reject) => {
    let reader = new FileReader();
    let files = event.target.files;
    let len = files.length;
    if (len > 1) {
      reject(new DOMException("Only one file can be uploaded at a time"));
    } else {
      reader.onerror = () => {
        reader.abort();
        reject(new DOMException("Problem parsing input file."));
      };
      let file = files[0]
      reader.onload = (evt) => {
        const uint = new Uint8Array(evt.target.result);
        let bytes = [];
        uint.map(byte => {
          bytes.push(byte.toString(16));
        });
        const hex = bytes.join('').toUpperCase();
        let base64 = reader.result.split(',')[1];
        file.base64 = base64;
        file.binaryFileType = getMimetype(hex);
        resolve(file);
      };
      reader.readAsDataURL(file);
    }
  });
}

Replace code with

module.exports = function (event) {
  return new Promise(function(resolve, reject)  {
    let reader = new FileReader();
    let files = event.target.files;
    let len = files.length;
    if (len > 1) {
      reject(new DOMException("Only one file can be uploaded at a time"));
    } else {
      reader.onerror = function() {
        reader.abort();
        reject(new DOMException("Problem parsing input file."));
      };
      let file = files[0]
      reader.onload = function(evt){
        const uint = new Uint8Array(evt.target.result);
        let bytes = [];
        uint.map(function(byte) {
          bytes.push(byte.toString(16));
        });
        const hex = bytes.join('').toUpperCase();
        let base64 = reader.result.split(',')[1];
        file.base64 = base64;
        file.binaryFileType = getMimetype(hex);
        resolve(file);
      };
      reader.readAsDataURL(file);
    }
  });
}

Over To You!

Check out full StackOverFlow thread for more details about solution.

Discussion (0)