systemjs
Version:
Dynamic ES module loader
2 lines (1 loc) • 1.62 kB
JavaScript
!function(){function t(t,e){return(e||"")+" (SystemJS https://git.io/JvFET#"+t+")"}!function(e){var n=e.System.constructor.prototype,r=n.instantiate;n.shouldFetch=function(t){var e=t.split("?")[0].split("#")[0];return e.slice(e.lastIndexOf(".")).match(/\.(css|html|json|wasm)$/)},n.fetch=function(t){return fetch(t)},n.instantiate=function(e,n){var i=this;return this.shouldFetch(e)?this.fetch(e).then((function(r){if(!r.ok)throw Error(t(7,[r.status,r.statusText,e,n].join(", ")));var s=r.headers.get("content-type");if(!s)throw Error(t(4,[e,n]));if(s.match(/^(text|application)\/(x-)?javascript(;|$)/))return r.text().then((function(t){return(0,eval)(t),i.getRegister()}));if(s.match(/^application\/json(;|$)/))return r.text().then((function(t){return[[],function(e){return{execute:function(){e("default",JSON.parse(t))}}}]}));if(s.match(/^text\/css(;|$)/))return r.text().then((function(t){return[[],function(e){return{execute:function(){var n=new CSSStyleSheet;n.replaceSync(t),e("default",n)}}}]}));if(s.match(/^application\/wasm(;|$)/))return(WebAssembly.compileStreaming?WebAssembly.compileStreaming(r):r.arrayBuffer().then(WebAssembly.compile)).then((function(t){var e=[],n=[],r={};return WebAssembly.Module.imports&&WebAssembly.Module.imports(t).forEach((function(t){var i=t.module;-1===e.indexOf(i)&&(e.push(i),n.push((function(t){r[i]=t})))})),[e,function(e){return{setters:n,execute:function(){return WebAssembly.instantiate(t,r).then((function(t){e(t.exports)}))}}}]}));throw Error(t(4,s))})):r.apply(this,arguments)}}("undefined"!=typeof self?self:global)}();//# sourceMappingURL=module-types.min.js.map