stefanpenner / es6-promise

A polyfill for ES6-style Promises
MIT License
7.3k stars 593 forks source link

Cannot find module "es6-promise" #327

Closed Legends closed 3 years ago

Legends commented 6 years ago

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.

marcusds commented 5 years ago

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

DecayConstant commented 3 years ago

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.