Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Polyfill for ie

I'm trying to add a polyfill to my vue.js 2.0/Laravel5.3 application because in internet explorer 11 I receive an error:

vuex requires a Promise polyfill in this browser.

So I've followed the docs I'm using ecm 6 so I did:

npm install --save-dev babel-polyfill

And added this at the top in my bootstrap.js:

import "babel-polyfill";

But still the same error in Internet explorer. What should I do or what am I doing wrong here?

like image 941
Jamie Avatar asked Jan 06 '17 13:01

Jamie


People also ask

How do I use polyfill in ie11?

To use a polyfill library, load it like any other JavaScript file or module. For example, you can use a <script> tag in the add-in's home page HTML file (for example <script src="/js/core-js. js"></script> ), or you can use an import statement in a JavaScript file (for example, import 'core-js'; ).

What is polyfill used for?

A polyfill is a piece of code (usually JavaScript on the Web) used to provide modern functionality on older browsers that do not natively support it.

Does ie11 support es2015?

Note: ECMAScript 2015 (ES6) is Partially Supported on Internet Explorer 11.

Does ie11 support fetch?

Fetch is Not Supported on Internet Explorer 11.


2 Answers

If you are using Webpack, find your webpack.base.conf.js file (mine was in the build folder), or the equivalent webpack configuration file, then modify the app entry variable to include babel-polyfill at the start so it looks something like this:

entry: {
    app: ['babel-polyfill', ...]
  },
  .
  .
  .
like image 81
Rashad Saleh Avatar answered Oct 11 '22 04:10

Rashad Saleh


@doulmi

Add this to your package.json file:

 "babel-polyfill": "^6.20.0"

After that npm install.

Add this at the top of you main js file:

import "babel-polyfill";

Compile everything. That should work.

like image 29
Jamie Avatar answered Oct 11 '22 04:10

Jamie