4

I am getting issue while using angular 6 and IE 11, app is working fine in chrome & another browser but in internet explorer, i am getting this

ERROR Error: Uncaught (in promise): Error: Loading chunk default~app-xxxxx~eb5ba6d4 failed. (missing: http://localhost:4200/default~app-xxxx.js) Error: Loading chunk default~app-xxxx~eb5ba6d4 failed. (missing: http://localhost:4200/default~app-xxxx~eb5ba6d4.js)

Project details

Angular CLI: 6.2.3 Node: 8.12.0 OS: win32 x64 Angular: ...

Package Version

@angular-devkit/architect 0.8.3 @angular-devkit/core 0.8.3 @angular-devkit/schematics 0.8.3 @schematics/angular 0.8.3 @schematics/update 0.8.3 rxjs 6.2.2 typescript 2.9.2

My app routing is

const routes: Routes = [
    {
        path: '',
        loadChildren:  'app/content/pages/pages.module#PagesModule'

    },
    {
        path: 'layout',
        loadChildren: 'app/content/layout/layout.module#LayoutModule',      
    },
    {
        path: '**',
        redirectTo: ''
    }
];
BJ Coder
  • 350
  • 5
  • 16
  • do you see anything (like a 404) in the dev console's network tab? – Arikael Mar 15 '19 at 10:06
  • @Arikael no nothing to see like 404 – BJ Coder Mar 15 '19 at 10:51
  • what is the http status of the file? Or do you see nothing at all? We once had the problem that some AdBlocker interfered – Arikael Mar 15 '19 at 11:34
  • Try to update the related packages, can you post the Enough code to reproduce the problem as in [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve). – Zhi Lv Mar 18 '19 at 07:26

6 Answers6

2

After investing some hours finally found my solutions Issue about promise((t,n) => ,

  1. At first, open the src/polyfills.ts file, and uncomment
/** 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.

  1. Install some packages

    npm install --save web-animations-js

    npm install --save classlist.js

Then i was 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);
    }
  });
}
BJ Coder
  • 350
  • 5
  • 16
  • > lambda expression does not support in IE, maybe you can change som settings in your tsconfig.json-file instead to fix this: `"module": "es2015"`, and `"target":"es5"` – John Mar 18 '19 at 10:25
1

I think you need to add some polyfills. If you open the src/polyfills.ts file, you need to uncomment these imports:

/** 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';

EDIT:

There might be more polyfils listed below this list, as mentioned by @Arikael in the comments, that you might want to uncomment as well.

John
  • 10,165
  • 5
  • 55
  • 71
  • below these lines there is `/** IE10 and IE11 requires the following for the Reflect API. */ import 'core-js/es6/reflect';` Did you uncomment this too? – Arikael Mar 15 '19 at 11:35
  • @Arikael yes "core-js/es6/reflect" already uncommented but still same issue – BJ Coder Mar 15 '19 at 14:01
1

You have to add meta tag.

<meta http-equiv="X-UA-Compatible" content="IE=edge" >
Puneet Uppal
  • 195
  • 10
0

Can you check the steps from this? this was the issue with IE

Angular CLI applications require a few more steps in order to support Internet Explorer.

RSJ
  • 41
  • 4
0

I am new at angular. I have faced an error about "loading chunk xyz module failed" in Internet Explorer. I had tried lots of things but no solution. Finally I changed adding order of "declarations" array and "imports" array in NgModule definition. I mean defining "declarations" before "imports" in NgModule() solved my problem.

@NgModule({
  declarations: [SomeComponent],
  imports: [
    FormsModule,
    ReactiveFormsModule,
    CommonModule,
    MaterialModule,
    TranslateModule.forChild({
      loader: {
        provide: TranslateLoader,
        useFactory: translateHttpLoaderFactory,
        deps: [HttpClient]
      }
    })
  ]
})
AbdurrahmanY
  • 809
  • 13
  • 22
0

This happens if a chunk could not be loaded, which will happen more often on mobile due to poor connections. You need to have some error handling in case a chunk failed to load, such as asking the user to reload the page.

ref

Muhammed Moussa
  • 4,589
  • 33
  • 27