In this article, I am going to provide the steps to fix an issue for the Angular SPFx WebPart to run in the Internet Explorer 11 (IE11).
While the Angular SPFx web part runs in the Internet Explorer 11, it will throw the below error.
A proper solution to this issue for the SPFx is to import the core-js polyfills in your WebPart.
To resolve the above issue, follow the below steps.
Step 1 - Create Angular SPFx WebPart
Create an SPFX WebPart and integrate Angular in your SPFx WebPart.
Step 2 - Add core-js package in your WebPart
Go to the Node.js command prompt and make sure you are pointing the project directory and running the below command to include “core-js” package in your WebPart.
npm install core-js
Step 3 - Add Polyfills.ts file in your WebPart
Create a Polyfills.ts file in your WebPart and import the below code in the Polyfills.ts.
- 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';
-
- if (WeakMap.toString().indexOf('function WeakMap()') === -1) {
- WeakMap = undefined;
- }
- import 'core-js/es6/weak-map';
-
- if (Map.toString().indexOf('function Map()') === -1) {
- Map = undefined;
- }
- import 'core-js/es6/map';
-
- if (Set.toString().indexOf('function Set()') === -1) {
- Set = undefined;
- }
- import 'core-js/es6/set';
- export class Polyfills {
- }
Step 4 - Import code in WebPart.ts file.
- Import the Polyfills file in your WebPart.ts file.
import { Polyfills } from './Polyfills';
- Import es6 reflect in the WebPart.ts file to provide intercepting Javascript operations.
import 'core-js/es6/reflect';
- Paste the below code in the top of the render() method in the WebPart.ts file
window['polyfills'] = Polyfills;
Now, the Angular SPFx WebPart runs in the Internet Explorer 11.
I have attached a sample Angular SPFx WebPart Solution for your reference which has the solution for the IE11 issue.
I hope you learned how to solve the "Error: Out of stack space" issue in IE11.