Search code examples
webpackwebpack-2aurelia

How to include an ES6 Promise when using the Aurelia-Webpack plugin?


I am using Aurelia 1.1 with the Webpack 2.0 plugin. This works fine in Chrome, but in IE, there is no promise.

So I get an error message on this:

var startPromise = new Promise(function (resolve) {
  return startResolve = resolve;
});

I have downloaded the es6 polyfill with npm, but I don't know how to tell webpack to include it so it can be used universally.

How should I be including this polyfill?


Solution

  • The usual thing for ES6 apps is to have polyfills included (e.g. core-js). This should be done once per app, as early as possible, before other libraries:

    import 'core-js/es6';
    

    Considering that aurelia-polyfills is already used, polyfills can be included selectively to not collide with the ones from aurelia-polyfills:

    import 'core-js/es6/promise';
    import 'core-js/es6/function';
    ...