typeof global != 'undefined' || (window.global = window);

var dirname;
var filename = '/module.js';
var scripts = document.scripts;
var head = scripts[0].parentNode

var length = scripts.length;
var src;
for (var i = 0; i < length; ++i) {
  src = scripts[i].src;
  if (src.indexOf(filename) > 0 )
    dirname = src.split(filename)[0] + '/';
    break;
}

global.console && console.log(dirname + 'module.js');

function expand(path, parent) {
  if (path == '.') {
    return path;
  }
  
  if (path.lastIndexOf('.js') != path.length - 3) {
    path += '.js';
  }
  
  return path;
}

function require(id, name) {
  path = expand(id);
  if (!require.cache[path]) {
    console.log('not cached: ' + path);
    require.cache[path] =  new Module(id);
    load(path);
  }
  return require.cache[path].exports;
}

require.cache = {};

function load(url, callback) {
  //callback(err, parent)
  url = expand(dirname + url);
  
  var script = document.createElement('script');
  
  script.src = url;
  script.onload = script.onreadystatechange = function () {
    if (!script.readyState || script.readyState.match(/loaded|complete/i)) {
      script.onload = script.onreadystatechange = null;
      resolve(url);
    }
  }
  
  script.onerror = function (e) {
    console.error('error loading script: ' + e);
    //module.pathError(filename);
  }
  
  head.appendChild(script);
}

function resolve(url) {
  
  console.log('url loaded: ' + url);
  require.cache[url].loaded = true;
}


function Module(id) {
  this.id = id;
  this.filename = id + '.js';
  this.exports = {};
  this.children = [];
  this.parent;
  this.loaded = false;
}


function define(id) {
  var path = expand(id);
  if (!require.cache[path]) {
    require.cache[path] = new Module(id);
  }
  global.module = require.cache[path];
}


// start
define('.');
;(function() {

  global.define = define;
  global.require = require;
  
}());


// emulate concatenated src
define('./inline');
;(function() {

  global.console && console.log('inline defined');
  
  module.exports = inline; function inline(caller) {
    
    global.console && console.log('inline.js called by ' + caller);

  }
  
}());

@@ -420,20 +420,18 @@
  expand(
-path
+id
 , parent
@@ -440,20 +440,18 @@
 %7B%0A  if (
-path
+id
  == '.')
@@ -464,20 +464,18 @@
  return 
-path
+id
 ;%0A  %7D%0A  
@@ -481,20 +481,18 @@
  %0A  if (
-path
+id
 .lastInd
@@ -506,20 +506,18 @@
 js') != 
-path
+id
 .length 
@@ -527,20 +527,18 @@
 ) %7B%0A    
-path
+id
  += '.js
@@ -556,20 +556,18 @@
  return 
-path
+id
 ;%0A%7D%0A%0Afun
@@ -594,16 +594,20 @@
 me) %7B%0A  
+var 
 path = e
@@ -826,19 +826,18 @@
 on load(
-url
+id
 , callba
@@ -874,21 +874,19 @@
 )%0A  
-url = expand(
+var path = 
 dirn
@@ -891,19 +891,25 @@
 rname + 
-url
+expand(id
 );%0A  %0A  
@@ -973,19 +973,20 @@
 t.src = 
-url
+path
 ;%0A  scri
@@ -1186,19 +1186,18 @@
 resolve(
-url
+id
 );%0A    %7D
@@ -1376,19 +1376,18 @@
 resolve(
-url
+id
 ) %7B%0A  %0A 
@@ -1400,19 +1400,18 @@
 le.log('
-url
+id
  loaded:
@@ -1415,19 +1415,18 @@
 ed: ' + 
-url
+id
 );%0A  req
@@ -1440,11 +1440,10 @@
 che%5B
-url
+id
 %5D.lo

Update module.js