Reputation: 4144
I'm using SweetAlert2 and on IE 11 throws exception:
This package requires a Promise library, please include a shim to enable it in this browser (See: https://github.com/sweetalert2/sweetalert2/wiki/Migration-from-SweetAlert-to-SweetAlert2#1-ie-support)
Because IE 11 doesn't support Promises and needs to be added manually.
I'm using bluebird like so:
const Promise = require('bluebird');
const Swal = require('sweetalert2');
Swal.fire(...)
...
But still, sweetalert's check doesn't pass:
..
if (typeof Promise === 'undefined') {
error('This package requires a Promise library, please include a shim to enable it in this browser (See: https://github.com/sweetalert2/sweetalert2/wiki/Migration-from-SweetAlert-to-SweetAlert2#1-ie-support)');
}
..
How to fix it? Thanks.
Upvotes: 1
Views: 3738
Reputation: 3968
For those who are using Sweetalert2 directly by referencing it in pages:
This could also be fixed by including the below core js lib after Sweetalert2 lib
<script src="https://cdnjs.cloudflare.com/ajax/libs/core-js/2.4.1/core.js"></script>
Upvotes: 1
Reputation: 14921
You can fix it with the following:
window.Promise = require('bluebird');
This will load Promise as a global variable of your window instead of the file like you did with the const
.
I'm not sure how your file structure is, but if you have a file that loads all the dependencies, you can simply add the line above to the script that will be called before your other scripts.
For example:
// bootstrap.js
window.Promise = require('bluebird');
window.Swal = require('sweetalert2');
// app.js
require('./bootstrap');
Swal.fire(...);
Upvotes: 1