Skip to content

Instantly share code, notes, and snippets.

@yanyu0517
Created January 28, 2014 05:47
Show Gist options
  • Save yanyu0517/8662837 to your computer and use it in GitHub Desktop.
Save yanyu0517/8662837 to your computer and use it in GitHub Desktop.
define('moduleB', [], function(require, exports, module){
exports.B = 1
})
/*! SeaJS 2.0.0 | seajs.org/LICENSE.md */
(function(u,r){function x(a){return function(c){return Object.prototype.toString.call(c)==="[object "+a+"]"}}function R(a){a=a.replace(ka,"/");for(a=a.replace(la,"$1/");a.match(S);)a=a.replace(S,"/");return a}function T(a){a=R(a);ma.test(a)?a=a.slice(0,-1):na.test(a)||(a+=".js");return a.replace(":80/","/")}function U(a,c){return oa.test(a)?a:pa.test(a)?(c||v).match(H)[0]+a:qa.test(a)?(v.match(ra)||["/"])[0]+a.substring(1):j.base+a}function I(a,c){if(!a)return"";var b=a,d=j.alias,b=a=d&&J(d[b])?d[b]:
b,d=j.paths,f;if(d&&(f=b.match(sa))&&J(d[f[1]]))b=d[f[1]]+f[2];f=b;var K=j.vars;K&&-1<f.indexOf("{")&&(f=f.replace(ta,function(a,b){return J(K[b])?K[b]:a}));a=U(f,c);f=a=T(a);var b=j.map,e=f;if(b)for(d=0;d<b.length&&!(e=b[d],e=y(e)?e(f)||f:f.replace(e[0],e[1]),e!==f);d++);return e}function V(a,c){var b=a.sheet,d;if(W)b&&(d=!0);else if(b)try{b.cssRules&&(d=!0)}catch(f){"NS_ERROR_DOM_SECURITY_ERR"===f.name&&(d=!0)}setTimeout(function(){d?c():V(a,c)},20)}function ua(){if(z)return z;if(A&&"interactive"===
A.readyState)return A;for(var a=w.getElementsByTagName("script"),c=a.length-1;0<=c;c--){var b=a[c];if("interactive"===b.readyState)return A=b}}function B(a){this.uri=a;this.dependencies=[];this.exports=null;this.status=0}function s(a,c){if(C(a)){for(var b=[],d=0;d<a.length;d++)b[d]=s(a[d],c);return b}b={id:a,refUri:c};n("resolve",b);return b.uri||I(b.id,c)}function D(a,c){C(a)||(a=[a]);X(a,function(){for(var b=[],d=0;d<a.length;d++)b[d]=Y(l[a[d]]);c&&c.apply(u,b)})}function X(a,c){var b=Z(a);if(0===
b.length)c();else{n("load",b);for(var d=b.length,f=d,e=0;e<d;e++)(function(a){function b(c){c||(c=d);var f=Z(e.dependencies);0===f.length?c():$(e)?(f=p,f.push(f[0]),aa("Circular dependencies: "+f.join(" -> ")),p.length=0,c(!0)):(ba[a]=f,X(f,c))}function d(a){!a&&e.status<L&&(e.status=L);0===--f&&c()}var e=l[a];e.dependencies.length?b(function(b){function c(){d(b)}e.status<E?ca(a,c):c()}):e.status<E?ca(a,b):d()})(b[e])}}function ca(a,c){function b(){delete M[f];N[f]=!0;F&&(da(a,F),F=r);var b,c=G[f];
for(delete G[f];b=c.shift();)b()}l[a].status=va;var d={uri:a};n("fetch",d);var f=d.requestUri||a;if(N[f])c();else if(M[f])G[f].push(c);else{M[f]=!0;G[f]=[c];var e=j.charset;n("request",d={uri:a,requestUri:f,callback:b,charset:e});if(!d.requested){var d=d.requestUri,h=ea.test(d),g=q.createElement(h?"link":"script");if(e&&(e=y(e)?e(d):e))g.charset=e;var k=g;h&&(W||!("onload"in k))?setTimeout(function(){V(k,b)},1):k.onload=k.onerror=k.onreadystatechange=function(){wa.test(k.readyState)&&(k.onload=k.onerror=
k.onreadystatechange=null,!h&&!j.debug&&k.parentNode.removeChild(k),k=r,b())};h?(g.rel="stylesheet",g.href=d):(g.async=!0,g.src=d);z=g;fa?w.insertBefore(g,fa):w.appendChild(g);z=r}}}function xa(a,c,b){1===arguments.length&&(b=a,a=r);if(!C(c)&&y(b)){var d=[];b.toString().replace(ya,"").replace(za,function(a,b,c){c&&d.push(c)});c=d}var f={id:a,uri:s(a),deps:c,factory:b};if(!f.uri&&q.attachEvent){var e=ua();e?f.uri=e.src:aa("Failed to derive: "+b)}n("define",f);f.uri?da(f.uri,f):F=f}function da(a,c){var b=l[a]||
(l[a]=new B(a));b.status<E&&(b.id=c.id||a,b.dependencies=s(c.deps||[],a),b.factory=c.factory,b.factory!==r&&(b.status=E))}function Aa(a){function c(b){return s(b,a.uri)}function b(a){return Y(l[c(a)])}if(!a)return null;if(a.status>=ga)return a.exports;a.status=ga;b.resolve=c;b.async=function(a,d){D(c(a),d);return b};var d=a.factory,d=y(d)?d(b,a.exports={},a):d;a.exports=d===r?a.exports:d;a.status=Ba;return a.exports}function Z(a){for(var c=[],b=0;b<a.length;b++){var d=a[b];d&&(l[d]||(l[d]=new B(d))).status<
L&&c.push(d)}return c}function Y(a){var c=Aa(a);null===c&&(!a||!ea.test(a.uri))&&n("error",a);return c}function $(a){var c=ba[a.uri]||[];if(0===c.length)return!1;p.push(a.uri);a:{for(a=0;a<c.length;a++)for(var b=0;b<p.length;b++)if(p[b]===c[a]){a=!0;break a}a=!1}if(a){a=p[0];for(b=c.length-1;0<=b;b--)if(c[b]===a){c.splice(b,1);break}return!0}for(a=0;a<c.length;a++)if($(l[c[a]]))return!0;p.pop();return!1}function ha(a){var c=j.preload,b=c.length;b?D(s(c),function(){c.splice(0,b);ha(a)}):a()}function O(a){for(var c in a){var b=
a[c];if(b&&"plugins"===c){c="preload";for(var d=[],f=void 0;f=b.shift();)d.push(ia+"plugin-"+f);b=d}if((d=j[c])&&Ca(d))for(var g in b)d[g]=b[g];else C(d)?b=d.concat(b):"base"===c&&(b=T(U(b+"/"))),j[c]=b}n("config",a);return e}var m=u.seajs;if(!m||!m.version){var e=u.seajs={version:"2.0.0"},Ca=x("Object"),J=x("String"),C=Array.isArray||x("Array"),y=x("Function"),aa=e.log=function(a,c){u.console&&(c||j.debug)&&console[c||(c="log")]&&console[c](a)},t=e.events={};e.on=function(a,c){if(!c)return e;(t[a]||
(t[a]=[])).push(c);return e};e.off=function(a,c){if(!a&&!c)return e.events=t={},e;var b=t[a];if(b)if(c)for(var d=b.length-1;0<=d;d--)b[d]===c&&b.splice(d,1);else delete t[a];return e};var n=e.emit=function(a,c){var b=t[a],d;if(b)for(b=b.slice();d=b.shift();)d(c);return e},H=/[^?#]*\//,ka=/\/\.\//g,la=/([^:\/])\/\/+/g,S=/\/[^/]+\/\.\.\//g,na=/\?|\.(?:css|js)$|\/$/,ma=/#$/,sa=/^([^/:]+)(\/.+)$/,ta=/{([^{]+)}/g,oa=/:\//,pa=/^\./,qa=/^\//,ra=/^.*?\/\/.*?\//,q=document,h=location,v=h.href.match(H)[0],
g=q.getElementsByTagName("script"),g=q.getElementById("seajsnode")||g[g.length-1],ia=(g.hasAttribute?g.src:g.getAttribute("src",4)).match(H)[0]||v;e.cwd=function(a){return a?v=R(a+"/"):v};var w=q.getElementsByTagName("head")[0]||q.documentElement,fa=w.getElementsByTagName("base")[0],ea=/\.css(?:\?|$)/i,wa=/^(?:loaded|complete|undefined)$/,z,A,W=536>1*navigator.userAgent.replace(/.*AppleWebKit\/(\d+)\..*/,"$1"),za=/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'|\/\*[\S\s]*?\*\/|\/(?:\\\/|[^/\r\n])+\/(?=[^\/])|\/\/.*|\.\s*require|(?:^|[^$])\brequire\s*\(\s*(["'])(.+?)\1\s*\)/g,
ya=/\\\\/g,l=e.cache={},F,M={},N={},G={},ba={},va=1,E=2,L=3,ga=4,Ba=5;B.prototype.destroy=function(){delete l[this.uri];delete N[this.uri]};var p=[];e.use=function(a,c){ha(function(){D(s(a),c)});return e};B.load=D;e.resolve=I;u.define=xa;e.require=function(a){return(l[I(a)]||{}).exports};var P=ia,ja=P.match(/^(.+?\/)(?:seajs\/)+(?:\d[^/]+\/)?$/);ja&&(P=ja[1]);var j=O.data={base:P,charset:"utf-8",preload:[]};e.config=O;var Q,h=h.search.replace(/(seajs-\w+)(&|$)/g,"$1=1$2"),h=h+(" "+q.cookie);h.replace(/seajs-(\w+)=1/g,
function(a,c){(Q||(Q=[])).push(c)});O({plugins:Q});h=g.getAttribute("data-config");g=g.getAttribute("data-main");h&&j.preload.push(h);g&&e.use(g);if(m&&m.args){g=["define","config","use"];m=m.args;for(h=0;h<m.length;h+=2)e[g[m[h]]].apply(e,m[h+1])}}})(this);
//@ sourceMappingURL=sea.js.map
<html>
<head>
<script type="text/javascript" src="sea.js"></script>
<script type="text/javascript" src="seajsconfig.js"></script>
</head>
<body>
<script type="text/javascript">
seajs.use(['moduleA'], function(moduleA){
console.log(moduleA)
})
</script>
</body>
</html>
//modify js url to include version
(function(){
seajs.config({
alias: {
//libs
'moduleA': 'moduleA.js',
'moduleB': 'moduleB.js'
},
preload: [],
debug: false,
map: [
],
charset: 'utf-8'
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment