From 8df68568e37971336931ecb6dda00a9935098362 Mon Sep 17 00:00:00 2001 From: Jonas Aschenbrenner Date: Sun, 18 May 2014 02:00:08 +0200 Subject: [PATCH] fix: Registering minified modules without dependencies throws error --- dist/system-production-csp.js | 2 +- dist/system-production-csp.min.js | 2 +- dist/system.js | 2 +- dist/system.min.js | 2 +- lib/extension-register.js | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dist/system-production-csp.js b/dist/system-production-csp.js index eb7df09f..0639b1e0 100644 --- a/dist/system-production-csp.js +++ b/dist/system-production-csp.js @@ -322,7 +322,7 @@ function register(loader) { } else { // ES6 declarative - if (declare.length != 1) + if (deps.length > 0 && declare.length != 1) throw 'Invalid System.register form for ' + name + '. Declare function must take one argument.'; register = { declarative: true, diff --git a/dist/system-production-csp.min.js b/dist/system-production-csp.min.js index 735e0e30..b1239e4a 100644 --- a/dist/system-production-csp.min.js +++ b/dist/system-production-csp.min.js @@ -5,4 +5,4 @@ * MIT License */ -!function(__$global){function __eval(__source,__global,__address,__sourceMap){try{__source=(__global!=__$global?"with(__global) { (function() { "+__source+" \n }).call(__global); }":__source)+"\n//# sourceURL="+__address+(__sourceMap?"\n//# sourceMappingURL="+__sourceMap:""),eval(__source)}catch(e){throw"SyntaxError"==e.name&&(e.message="Evaluating "+__address+"\n "+e.message),e}}__$global.upgradeSystemLoader=function(){function e(e){var t=String(e).replace(/^\s+|\s+$/g,"").match(/^([^:\/?#]+:)?(\/\/(?:[^:@]*(?::[^:@]*)?@)?(([^:\/?#]*)(?::(\d*))?))?([^?#]*)(\?[^#]*)?(#[\s\S]*)?/);return t?{href:t[0]||"",protocol:t[1]||"",authority:t[2]||"",host:t[3]||"",hostname:t[4]||"",port:t[5]||"",pathname:t[6]||"",search:t[7]||"",hash:t[8]||""}:null}function t(t,a){function r(e){var t=[];return e.replace(/^(\.\.?(\/|$))+/,"").replace(/\/(\.(\/|$))+/g,"/").replace(/\/\.\.$/,"/../").replace(/\/?[^\/]*/g,function(e){"/.."===e?t.pop():t.push(e)}),t.join("").replace(/^\//,"/"===e.charAt(0)?"/":"")}return a=e(a||""),t=e(t||""),a&&t?(a.protocol||t.protocol)+(a.protocol||a.authority?a.authority:t.authority)+r(a.protocol||a.authority||"/"===a.pathname.charAt(0)?a.pathname:a.pathname?(t.authority&&!t.pathname?"/":"")+t.pathname.slice(0,t.pathname.lastIndexOf("/")+1)+a.pathname:t.pathname)+(a.protocol||a.authority||a.pathname?a.search:a.search||t.search)+a.hash:null}function a(e){"undefined"==typeof p&&(p=Array.prototype.indexOf);var t=document.getElementsByTagName("head")[0];e.onScriptLoad=function(){},e.fetch=function(a){return new Promise(function(r,n){function o(){l.readyState&&"loaded"!=l.readyState&&"complete"!=l.readyState||(i(),e.onScriptLoad(a),r(""))}function i(){l.detachEvent?l.detachEvent("onreadystatechange",o):(l.removeEventListener("load",o,!1),l.removeEventListener("error",err,!1)),t.removeChild(l)}var l=document.createElement("script");l.async=!0,l.attachEvent&&l.attachEvent("onreadystatechange",o),l.addEventListener("load",o,!1),l.addEventListener("error",err,!1),l.src=a.address,t.appendChild(l)})},e.scriptLoader=!0}function r(e){function t(e,t){var a=e.meta&&e.meta[t.name];if(a)for(var r in a)t.metadata[r]=t.metadata[r]||a[r]}var a=/^(\s*\/\*.*\*\/|\s*\/\/[^\n]*|\s*"[^"]+"\s*;?|\s*'[^']+'\s*;?)+/,r=/\/\*.*\*\/|\/\/[^\n]*|"[^"]+"\s*;?|'[^']+'\s*;?/g;e.meta={};var n=e.locate;e.locate=function(e){return t(this,e),n.call(this,e)};var o=e.translate;e.translate=function(e){var n=e.source.match(a);if(n)for(var i=n[0].match(r),l=0;l=0;o--){for(var l=r[o],u=0;ur.length)return 0;for(var n=0;nparseInt(n[o])?1:-1}return 0};e.versions=e.versions||{};var r=e.normalize;e.normalize=function(n,o,i){e.versions||(e.versions={});var l=this.versions;return Promise.resolve(r.call(this,n,o,i)).then(function(e){var r,n,o,i,s=e.indexOf("@");if(-1==s||0==s){for(var u in l)if(i=l[u],e.substr(0,u.length)==u&&(o=e.substr(u.length,1),!o||"/"==o))return u+"@"+("string"==typeof i?i:i[i.length-1])+e.substr(u.length);return e}r=e.substr(s+1).split("/")[0];var d,c=r.length;if("^"==r.substr(0,1)&&(r=r.substr(1),d=!0),n=r.match(t),!n)return e;d&&(n[2]||(d=!1),n[3]||(n[2]>0?n[3]="0":d=!1)),d&&(n[1]>0?(n[2]||(r=n[1]+".0.0"),n[3]||(r=n[1]+".0"),d=r,n=[n[1]]):n[2]>0?(d=r,n=[0,n[2]]):(d=!1,n=[0,0,n[3]]),r=n.join("."));var f=e.substr(0,s);if(i=l[f]||[],"string"==typeof i&&(i=[i]),!n[3]||d)for(var m=i.length-1;m>=0;m--){var g=i[m];if(g.substr(0,r.length)==r&&g.substr(r.length,1).match(/^[\.\-]?$/)&&(!d||d&&-1!=a(g,d)))return f+"@"+g+e.substr(f.length+c+1)}return-1==p.call(i,r)&&(i.push(r),i.sort(a),e=f+"@"+r+e.substr(f.length+c+1),n[3]&&-1!=(s=p.call(i,n[1]+"."+n[2]))&&i.splice(s,1),n[2]&&-1!=(s=p.call(i,n[1]))&&i.splice(s,1),l[f]=1==i.length?i[0]:i),e})}}function f(e){e.depCache=e.depCache||{},loaderLocate=e.locate,e.locate=function(e){var t=this;t.depCache||(t.depCache={});var a=t.depCache[e.name];if(a)for(var r=0;rt;t++)if(this[t]===e)return t;return-1},m=__$global.System,g=__$global.System=new LoaderPolyfill(m);if(g.baseURL=m.baseURL,g.paths={"*":"*.js"},g.originalSystem=m,g.noConflict=function(){__$global.SystemJS=g,__$global.System=g.originalSystem},a(g),r(g),n(g),o(g),i(g),l(g),s(g),u(g),d(g),c(g),f(g),__$curScript){g.baseURL=__$curScript.getAttribute("data-baseurl")||__$curScript.getAttribute("baseurl")||g.baseURL;var h=__$curScript.getAttribute("data-config")||__$curScript.getAttribute("config");h&&"/"===h.substr(h.length-1)&&(h+="config.json");var v=__$curScript.getAttribute("data-main")||__$curScript.getAttribute("main");g.paths["@traceur"]||(g.paths["@traceur"]="undefined"!=typeof __$curScript&&__$curScript.getAttribute("data-traceur-src")||g.baseURL+(g.baseURL.lastIndexOf("/")==g.baseURL.length-1?"":"/")+"traceur.js"),(h?Promise.resolve(g.fetch.call(g,{address:h,metadata:{}})).then(JSON.parse).then(g.config):Promise.resolve()).then(function(){return v?g["import"](v):void 0})["catch"](function(e){setTimeout(function(){throw e})})}};var __$curScript;!function(e){if("undefined"!=typeof window){var t=document.getElementsByTagName("script");if(__$curScript=t[t.length-1],!e.System||e.System.registerModule){var a=__$curScript.src,r=a.substr(0,a.lastIndexOf("/")+1);document.write('')}else e.upgradeSystemLoader()}else{var n=require("es6-module-loader");e.System=n.System,e.Loader=n.Loader,e.Module=n.Module,e.upgradeSystemLoader(),module.exports=e.System}}(__$global)}("undefined"!=typeof window?window:global); \ No newline at end of file diff --git a/dist/system.js b/dist/system.js index 2cca6423..a128794e 100644 --- a/dist/system.js +++ b/dist/system.js @@ -263,7 +263,7 @@ function register(loader) { } else { // ES6 declarative - if (declare.length != 1) + if (deps.length > 0 && declare.length != 1) throw 'Invalid System.register form for ' + name + '. Declare function must take one argument.'; register = { declarative: true, diff --git a/dist/system.min.js b/dist/system.min.js index 2eb0470b..8fe0b0f0 100644 --- a/dist/system.min.js +++ b/dist/system.min.js @@ -5,4 +5,4 @@ * MIT License */ -!function(__$global){function __eval(__source,__global,__address,__sourceMap){try{__source=(__global!=__$global?"with(__global) { (function() { "+__source+" \n }).call(__global); }":__source)+"\n//# sourceURL="+__address+(__sourceMap?"\n//# sourceMappingURL="+__sourceMap:""),eval(__source)}catch(e){throw"SyntaxError"==e.name&&(e.message="Evaluating "+__address+"\n "+e.message),e}}__$global.upgradeSystemLoader=function(){function e(e){var t=String(e).replace(/^\s+|\s+$/g,"").match(/^([^:\/?#]+:)?(\/\/(?:[^:@]*(?::[^:@]*)?@)?(([^:\/?#]*)(?::(\d*))?))?([^?#]*)(\?[^#]*)?(#[\s\S]*)?/);return t?{href:t[0]||"",protocol:t[1]||"",authority:t[2]||"",host:t[3]||"",hostname:t[4]||"",port:t[5]||"",pathname:t[6]||"",search:t[7]||"",hash:t[8]||""}:null}function t(t,a){function r(e){var t=[];return e.replace(/^(\.\.?(\/|$))+/,"").replace(/\/(\.(\/|$))+/g,"/").replace(/\/\.\.$/,"/../").replace(/\/?[^\/]*/g,function(e){"/.."===e?t.pop():t.push(e)}),t.join("").replace(/^\//,"/"===e.charAt(0)?"/":"")}return a=e(a||""),t=e(t||""),a&&t?(a.protocol||t.protocol)+(a.protocol||a.authority?a.authority:t.authority)+r(a.protocol||a.authority||"/"===a.pathname.charAt(0)?a.pathname:a.pathname?(t.authority&&!t.pathname?"/":"")+t.pathname.slice(0,t.pathname.lastIndexOf("/")+1)+a.pathname:t.pathname)+(a.protocol||a.authority||a.pathname?a.search:a.search||t.search)+a.hash:null}function a(e){function t(e,t){var a=e.meta&&e.meta[t.name];if(a)for(var r in a)t.metadata[r]=t.metadata[r]||a[r]}var a=/^(\s*\/\*.*\*\/|\s*\/\/[^\n]*|\s*"[^"]+"\s*;?|\s*'[^']+'\s*;?)+/,r=/\/\*.*\*\/|\/\/[^\n]*|"[^"]+"\s*;?|'[^']+'\s*;?/g;e.meta={};var n=e.locate;e.locate=function(e){return t(this,e),n.call(this,e)};var o=e.translate;e.translate=function(e){var n=e.source.match(a);if(n)for(var l=n[0].match(r),i=0;i=0;o--){for(var i=r[o],u=0;ur.length)return 0;for(var n=0;nparseInt(n[o])?1:-1}return 0};e.versions=e.versions||{};var r=e.normalize;e.normalize=function(n,o,l){e.versions||(e.versions={});var i=this.versions;return Promise.resolve(r.call(this,n,o,l)).then(function(e){var r,n,o,l,s=e.indexOf("@");if(-1==s||0==s){for(var u in i)if(l=i[u],e.substr(0,u.length)==u&&(o=e.substr(u.length,1),!o||"/"==o))return u+"@"+("string"==typeof l?l:l[l.length-1])+e.substr(u.length);return e}r=e.substr(s+1).split("/")[0];var d,c=r.length;if("^"==r.substr(0,1)&&(r=r.substr(1),d=!0),n=r.match(t),!n)return e;d&&(n[2]||(d=!1),n[3]||(n[2]>0?n[3]="0":d=!1)),d&&(n[1]>0?(n[2]||(r=n[1]+".0.0"),n[3]||(r=n[1]+".0"),d=r,n=[n[1]]):n[2]>0?(d=r,n=[0,n[2]]):(d=!1,n=[0,0,n[3]]),r=n.join("."));var f=e.substr(0,s);if(l=i[f]||[],"string"==typeof l&&(l=[l]),!n[3]||d)for(var m=l.length-1;m>=0;m--){var g=l[m];if(g.substr(0,r.length)==r&&g.substr(r.length,1).match(/^[\.\-]?$/)&&(!d||d&&-1!=a(g,d)))return f+"@"+g+e.substr(f.length+c+1)}return-1==p.call(l,r)&&(l.push(r),l.sort(a),e=f+"@"+r+e.substr(f.length+c+1),n[3]&&-1!=(s=p.call(l,n[1]+"."+n[2]))&&l.splice(s,1),n[2]&&-1!=(s=p.call(l,n[1]))&&l.splice(s,1),i[f]=1==l.length?l[0]:l),e})}}function f(e){e.depCache=e.depCache||{},loaderLocate=e.locate,e.locate=function(e){var t=this;t.depCache||(t.depCache={});var a=t.depCache[e.name];if(a)for(var r=0;rt;t++)if(this[t]===e)return t;return-1},m=__$global.System,g=__$global.System=new LoaderPolyfill(m);if(g.baseURL=m.baseURL,g.paths={"*":"*.js"},g.originalSystem=m,g.noConflict=function(){__$global.SystemJS=g,__$global.System=g.originalSystem},a(g),r(g),n(g),o(g),l(g),i(g),s(g),u(g),d(g),c(g),f(g),__$curScript){g.baseURL=__$curScript.getAttribute("data-baseurl")||__$curScript.getAttribute("baseurl")||g.baseURL;var h=__$curScript.getAttribute("data-config")||__$curScript.getAttribute("config");h&&"/"===h.substr(h.length-1)&&(h+="config.json");var v=__$curScript.getAttribute("data-main")||__$curScript.getAttribute("main");g.paths["@traceur"]||(g.paths["@traceur"]="undefined"!=typeof __$curScript&&__$curScript.getAttribute("data-traceur-src")||g.baseURL+(g.baseURL.lastIndexOf("/")==g.baseURL.length-1?"":"/")+"traceur.js"),(h?Promise.resolve(g.fetch.call(g,{address:h,metadata:{}})).then(JSON.parse).then(g.config):Promise.resolve()).then(function(){return v?g["import"](v):void 0})["catch"](function(e){setTimeout(function(){throw e})})}};var __$curScript;!function(e){if("undefined"!=typeof window){var t=document.getElementsByTagName("script");if(__$curScript=t[t.length-1],!e.System||e.System.registerModule){var a=__$curScript.src,r=a.substr(0,a.lastIndexOf("/")+1);document.write('')}else e.upgradeSystemLoader()}else{var n=require("es6-module-loader");e.System=n.System,e.Loader=n.Loader,e.Module=n.Module,e.upgradeSystemLoader(),module.exports=e.System}}(__$global)}("undefined"!=typeof window?window:global); \ No newline at end of file diff --git a/lib/extension-register.js b/lib/extension-register.js index b5f38b80..19dd1766 100644 --- a/lib/extension-register.js +++ b/lib/extension-register.js @@ -97,7 +97,7 @@ function register(loader) { } else { // ES6 declarative - if (declare.length != 1) + if (deps.length > 0 && declare.length != 1) throw 'Invalid System.register form for ' + name + '. Declare function must take one argument.'; register = { declarative: true,