systemjs / systemjs

Dynamic ES module loader
MIT License
12.94k stars 1.08k forks source link

`import` is the keyword in IE even it's a property #2251

Closed axetroy closed 4 years ago

axetroy commented 4 years ago
  function SystemJS () {
    this[REGISTRY] = {};
  }

  var systemJSPrototype = SystemJS.prototype;

  systemJSPrototype.import = function (id, parentUrl) {
    var loader = this;
    return Promise.resolve(loader.prepareImport())
    .then(function() {
      return loader.resolve(id, parentUrl);
    })
    .then(function (id) {
      var load = getOrCreateLoad(loader, id);
      return load.C || topLevelLoad(loader, load);
    });
  };

systemJSPrototype.import is work in the modern browser, but it doesn't work in IE

even

const obj = {
  import: () => {} // throw in IE
}

function Module () {}

Module.import = function () {} // throw in IE

System.import('/xxx.js'); // throw in IE

This makes system.js not work in IE(including IE11) at all.

axetroy commented 4 years ago

To make it works, I have to update system.js by manual.

repace all xxx.import to xxx['import']

guybedford commented 4 years ago

@axetroy officially only IE11 is supported. Also note that SystemJS script loads may have timing issues in earlier versions of IE due to the fact that the script callback cannot be relied to be synchronous in those versions.

So even if you can get it to work on IE9 you may have some loading bugs at some point as the number of modules increases.

joeldenning commented 4 years ago

To add to what Guy said, you must add the polyfills documented in https://github.com/systemjs/systemjs#ie11-support for it to work in IE11

axetroy commented 4 years ago

@joeldenning This is not a polyfill problem.

Is this my description is not clear enough?

I mean import is a keyword in IE(7,8,9,10,11).

Even if it's a property like object.import = function () {}

This will cause the exception to be unusable in IE.

This is not a problem that polyfills can solve.

guybedford commented 4 years ago

@axetroy as mentioned above there are other concerns here regarding IE<11 support. The only version of IE that is supported is IE11 (within which import is supported without quotes).