diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2611b69d..caf878a3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+SystemJS 4.0.1 (2019/07/06)
+* Fix IE11 regression related to loading json files (https://github.com/systemjs/systemjs/pull/1963, @joeldenning)
+* Fix bug where System.import() rejected incorrectly, due to unrelated errors (https://github.com/systemjs/systemjs/pull/1963)
+
SystemJS 4.0.0 (2019/06/29)
* Support `` setting baseURL (https://github.com/systemjs/systemjs/pull/1957, @LarsDenBakker)
* Use `Error` over `new Error` to reduce footprint (https://github.com/systemjs/systemjs/pull/1951, @joeldenning)
diff --git a/dist/s.js b/dist/s.js
index 30c5a4b8..d9103d75 100644
--- a/dist/s.js
+++ b/dist/s.js
@@ -1,5 +1,5 @@
/*
-* SJS 4.0.0
+* SJS 4.0.1
* Minimal SystemJS Build
*/
(function () {
@@ -364,12 +364,6 @@
* Supports loading System.register via script tag injection
*/
- let err;
- if (typeof window !== 'undefined')
- window.addEventListener('error', function (e) {
- err = e.error;
- });
-
const systemRegister = systemJSPrototype.register;
systemJSPrototype.register = function (deps, declare) {
err = undefined;
@@ -378,7 +372,7 @@
systemJSPrototype.instantiate = function (url, firstParentUrl) {
const loader = this;
- if (url.endsWith('.json')) {
+ if (url.substr(-5) === '.json') {
return fetch(url).then(function (resp) {
return resp.text();
}).then(function (source) {
@@ -388,19 +382,30 @@
});
} else {
return new Promise(function (resolve, reject) {
+ let err;
+
+ function windowErrorListener(evt) {
+ if (evt.filename === url)
+ err = evt.error;
+ }
+
+ window.addEventListener('error', windowErrorListener);
+
const script = document.createElement('script');
script.charset = 'utf-8';
script.async = true;
script.crossOrigin = 'anonymous';
script.addEventListener('error', function () {
+ window.removeEventListener('error', windowErrorListener);
reject(Error('Error loading ' + url + (firstParentUrl ? ' from ' + firstParentUrl : '')));
});
script.addEventListener('load', function () {
+ window.removeEventListener('error', windowErrorListener);
document.head.removeChild(script);
- // Note URL normalization issues are going to be a careful concern here
+ // Note that if an error occurs that isn't caught by this if statement,
+ // that getRegister will return null and a "did not instantiate" error will be thrown.
if (err) {
reject(err);
- return err = undefined;
}
else {
resolve(loader.getRegister());
diff --git a/dist/s.min.js b/dist/s.min.js
index 1eaa885b..a14d25f2 100644
--- a/dist/s.min.js
+++ b/dist/s.min.js
@@ -1 +1 @@
-!function(){const e="undefined"!=typeof self,n=e?self:global;let t;if("undefined"!=typeof document){const e=document.querySelector("base[href]");e&&(t=e.href)}if(!t&&"undefined"!=typeof location){const e=(t=location.href.split("#")[0].split("?")[0]).lastIndexOf("/");-1!==e&&(t=t.slice(0,e+1))}const r=/\\/g,o="undefined"!=typeof Symbol,i=o&&Symbol.toStringTag,c=o?Symbol():"@";function u(){this[c]={}}const s=u.prototype;let l;s.import=function(e,n){const t=this;return Promise.resolve(t.resolve(e,n)).then(function(e){const n=function e(n,t,r){let o=n[c][t];if(o)return o;const u=[],s=Object.create(null);i&&Object.defineProperty(s,i,{value:"Module"});let l=Promise.resolve().then(function(){return n.instantiate(t,r)}).then(function(e){if(!e)throw Error("Module "+t+" did not instantiate");const r=e[1](function(e,n){o.h=!0;let t=!1;if("object"!=typeof e)e in s&&s[e]===n||(s[e]=n,t=!0);else for(let n in e){let r=e[n];n in s&&s[n]===r||(s[n]=r,t=!0)}if(t)for(let e=0;en.length&&"/"!==o[o.length-1]&&console.warn("Invalid package target "+o+" for '"+n+"' should have a trailing '/'."),o+t.slice(n.length)}}const l="undefined"!=typeof Symbol,f=l&&Symbol.toStringTag,d=l?Symbol():"@";function a(){this[d]={}}const h=a.prototype;let p;h.import=function(t,e){const n=this;return Promise.resolve(n.resolve(t,e)).then(function(t){const e=function t(e,n,o){let r=e[d][n];if(r)return r;const i=[],c=Object.create(null);f&&Object.defineProperty(c,f,{value:"Module"});let s=Promise.resolve().then(function(){return e.instantiate(n,o)}).then(function(t){if(!t)throw Error("Module "+n+" did not instantiate");const o=t[1](function(t,e){r.h=!0;let n=!1;if("object"!=typeof t)t in c&&c[t]===e||(c[t]=e,n=!0);else for(let e in t){let o=t[e];e in c&&c[e]===o||(c[e]=o,n=!0)}if(n)for(let t=0;tn.length&&"/"!==o[o.length-1]&&console.warn("Invalid package target "+o+" for '"+n+"' should have a trailing '/'."),o+t.slice(n.length)}}const l="undefined"!=typeof Symbol,f=l&&Symbol.toStringTag,a=l?Symbol():"@";function d(){this[a]={}}const h=d.prototype;let p;h.import=function(t,e){const n=this;return Promise.resolve(n.resolve(t,e)).then(function(t){const e=function t(e,n,o){let r=e[a][n];if(r)return r;const i=[],c=Object.create(null);f&&Object.defineProperty(c,f,{value:"Module"});let s=Promise.resolve().then(function(){return e.instantiate(n,o)}).then(function(t){if(!t)throw Error("Module "+n+" did not instantiate");const o=t[1](function(t,e){r.h=!0;let n=!1;if("object"!=typeof t)t in c&&c[t]===e||(c[t]=e,n=!0);else for(let e in t){let o=t[e];e in c&&c[e]===o||(c[e]=o,n=!0)}if(n)for(let t=0;t