These are chat archives for systemjs/systemjs

3rd
Nov 2016
mtkastner
@mkastner
Nov 03 2016 13:45

How can I get this running in Internet Explorer (eg. 10/11)?

SystemJS.import('/js/test/promise-build-test.js');
require('babel/polyfill');

function test() {
    return new Promise(function(resolve, reject) {
        console.log('test');
        resolve('test');
    });
}

function *run() {
    console.log('test');
    return yield test();
}

Promise.coroutine(run)().catch(function(err) {
    console.error(err.stack);
});

At the moment bluebird is loaded via script-Tag. But when I do require('babel/polyfill') I get

Unhandled rejection (SystemJS) Promise.coroutine is not a function

So obviously the babel's polyfill promise ist overwriting the Bluebird promise.

What do I have to do in order to get the Bluebird Promise and coroutine transpiled to a version, which internet explorer actually can handle?

Tom Clement
@tjclement
Nov 03 2016 13:47
@mkastner You can load only the specific polyfills you need instead of the full 'babel-polyfill'
Also check out https://babeljs.io/docs/usage/polyfill/, where it explains that a bit more
mtkastner
@mkastner
Nov 03 2016 14:03

No kidding, I've read that. But it hasn't helped me very much. The recommended module I am using is: babel-plugin-transform-async-to-module-method. That's just one module. It should not override bluebird. I've followed the plugin-babel example for Bluebird:

System.config({
  baseURL: "/",
  defaultJSExtensions: true,
  transpiler: "plugin-babel",
  babelOptions: {
    "es2015": true,
    "plugins": [
      [
        "babel-plugin-transform-async-to-module-method",
        {
          "module": "bluebird",
          "method": "coroutine"
        }
      ]
    ],
    etc.

And the other plugins here are not that well documented. What I need is something which turns the promise and the generator function into a regular function during runtime i.e. development.

Tom Clement
@tjclement
Nov 03 2016 15:54
Sounds like you want to follow this example to install the regenerator runtime that Babel uses, along with babel-plugin-transform-regenerator in your jspm config
Note the blue "Runtime required" information box
mtkastner
@mkastner
Nov 03 2016 16:21
You're propably right. I am going to try that now.
mtkastner
@mkastner
Nov 03 2016 18:19

@tjclement I don't know why, but regenerator-runtime doesn't seem to work in internet explorer. Here's the example code:

require('regenerator-runtime');

function test() {
    return new Promise(function(resolve, reject) {
        console.log('test');
        resolve('test');
    });
}

Promise.coroutine(function*() {
    yield test();
})();

What happens is that the ie-javascript interpreter evaluates the code before regenerator-runtime can kick in. So it throws an "Unhandled rejection (SystemJS) '(' expected", since it hits the asterisk where it expects a parenthesis.

Should regenerator-runtime rather be invoked via the script-tag than via require?

Carson Full
@CarsonF
Nov 03 2016 19:20
Are there side effects of bundling modules but not specifying the bundles in your config?