‘Promise’ is undefined

Using the latest version of webpack as of today, i.e. v2.2.1
Some browsers log the following error: ‘Promise’ is undefined
One such browser is Mozilla/5.0 (Windows Phone 8.1; ARM; Trident/7.0; Touch; rv:11.0; IEMobile/11.0; NOKIA; Lumia 530) like Gecko

The following is the beginning of the webpack bundle and the offending statement is var l=new Promise at 1:1405 which, I think is webpack generated code:

!function(n){function e(t){if(i[t])return i[t].exports;var r=i[t]={i:t,l:!1,exports:{}};return n[t].call(r.exports,r,r.exports,e),r.l=!0,r.exports}var t=window.webpackJsonp;window.webpackJsonp=function(i,o,a){for(var l,s,d,p=0,c=[];p<i.length;p++)s=i[p],r[s]&&c.push(r[s][0]),r[s]=0;for(l in o)Object.prototype.hasOwnProperty.call(o,l)&&(n[l]=o[l]);for(t&&t(i,o,a);c.length;)c.shift()();if(a)for(p=0;p<a.length;p++)d=e(e.s=a[p]);return d};var i={},r={23:0};e.e=function(n){function t(){o.onerror=o.onload=null,clearTimeout(a);var e=r[n];0!==e&&(e&&e[1](new Error("Loading chunk "+n+" failed.")),r[n]=void 0)}if(0===r[n])return Promise.resolve();if(r[n])return r[n][2];var i=document.getElementsByTagName("head")[0],o=document.createElement("script");o.type="text/javascript",o.charset="utf-8",o.async=!0,o.timeout=12e4,e.nc&&o.setAttribute("nonce",e.nc),o.src=e.p+""+({0:"app.theme.moonlight",1:"app.theme.highcontrast",2:"app.theme.black",3:"app.theme.uniform",4:"app.theme.silver",5:"app.theme.metro",6:"app.theme.flat",7:"app.theme.default",8:"app.theme.blueopal",9:"app.theme.office365",10:"app.theme.metroblack",11:"app.theme.materialblack",12:"app.theme.material",13:"app.theme.fiori",14:"app.theme.bootstrap",15:"app.theme.nova",16:"app.culture.fr",17:"app.culture.en",18:"home",19:"page",20:"search",21:"post",22:"error"}[n]||n)+".chunk.js?v=0.2.86";var a=setTimeout(t,12e4);o.onerror=o.onload=t;var l=new Promise(function(e,t){r[n]=[e,t]});return r[n][2]=l,i.appendChild(o),l},e.m=n,e.c=i,e.i=function(n){return n},e.d=function(n,t,i){e.o(n,t)||Object.defineProperty(n,t,{configurable:!1,enumerable:!0,get:i})},e.n=function(n){var t=n&&n.__esModule?function(){return n.default}:function(){return n};return e.d(t,"a",t),t},e.o=function(n,e){return Object.prototype.hasOwnProperty.call(n,e)},e.p="http://www.memba.com/build/",e.oe=function(n){throw console.error(n),n}}([function(n,e){n.exports=function(){throw new Error("define cannot be used indirect")}},function(n,e,t){var i,r,o;!function(t,a){"use strict";r=[],i=t,o="function"==typeof i?i.apply(e,r):i,!(void 0!==o&&(n.exports=o))}(function(){"use strict";return function(n){var e="string",t="object",

Author: Fantashit

2 thoughts on “‘Promise’ is undefined

  1. I’ve got this problem too, and not sure how to add to fix. Some say to add it with provide plugin like

        new webpack.ProvidePlugin({
            $: "jquery",
            jQuery: "jquery",
            Promise: 'es6-promise'
        })
    
    

    but this does not work.

    Any same code around to fix this for IE in webpack without altering app source code?

Comments are closed.

Promise is undefined

Hi,
I get “Promise is undefined” error from sweetalert2.min.js.

 $.ajax({
        type: 'GET',
        url: url,
        data: {
            test: test
        },
        error: function (xhr, status, error) {
            swal('Sorry...!', 'Server Message: <br><br>' + error, 'error');
            // Throw expection "Promise is undefined"
        }
    }).done(function (data) {

    });

Thanks…

Author: Fantashit

3 thoughts on “Promise is undefined

  1. Most probably you’re getting this exception in IE.

    For IE support Promise polyfill should be included beside sweetalert2.js:

    <script src="https://cdnjs.cloudflare.com/ajax/libs/core-js/2.4.1/core.js"></script>

Comments are closed.