forked from popeindustries/simpler-browser-require
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrequire.min.js
1 lines (1 loc) · 1.06 KB
/
require.min.js
1
(function(root){function require(path){if(!this.module&&path.charAt(0)=="."){path=path.slice(path.indexOf("..")===0?3:2)}var m=require.modules[path]||require.modules[path+"/index"];if(!m){var p,p2,idx;for(var p in require.modules){if((idx=p.indexOf("#"))!=-1){p2=p.slice(0,idx);if(path==p2){m=require.modules[p];break}}}if(!m)throw"Couldn't find module for: "+path}if(!m.exports){if("string"==typeof m){m=require.modules[path]=new Function("module","exports","require",m)}m.exports={};m.filename=path;m.call(this,m,m.exports,require.relative(path))}return m.exports}require.modules={};require.resolve=function(from,to){var fromSegs=from.split("/"),seg;if(to.charAt(0)!=".")return to;if(fromSegs.length>1)fromSegs.pop();to=to.split("/");for(var i=0;i<to.length;++i){seg=to[i];if(seg==".."){fromSegs.pop()}else if(seg!="."){fromSegs.push(seg)}}return fromSegs.join("/")};require.relative=function(path){return function(p){return require(require.resolve(path,p))}};require.register=function(path,fn){require.modules[path]=fn};root.require=require})(typeof window!=="undefined"?window:global);