stefanpenner / es6-promise

A polyfill for ES6-style Promises

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot find module "es6-promise"

Legends opened this issue · comments

I want to load the polyfill on demand, but it cannot find the module.
I am using webpack!
It works the way I described below, to load lodash for example, but it cannot find the es6-promise module.

I can see that the bundle is created:

image

In my code editor I get a red squiggle, it cannot find the module.

if(!("Promise" in window)){ // <= IE11 no support for Promises 
    import(/* webpackChunkName: "es6-promise" */ 'es6-promise').then(function (p) {
       p.polyfill();
    }).catch(function (error) { console.log('An error occurred while loading the component es6-promise'); });
}

this doesn't work either:

import * as p from "es6-promise"

I don't want to require it, because then it gets bundeled with all other scripts.
I just want to load the polyfill when needed.

I would also like to load the module this way! It would great if this project support ES6 imports.

I don't think you can use Webpack's dynamic imports to polyfill Promises into an environment that doesn't already have them because the Dynamic Import process itself relies on Promises.