<script type="text/javascript">
void function(global)
{
var mapping = {}, cache = {};
global.define = function(id, func){
mapping[id] = func;
};
global.require = function(id){
if(cache[id])
return cache[id];
else
return cache[id] = mapping[id]({});
};
}(this);
define("moduleA", function(exports)
{
function ClassA(){
}
ClassA.prototype.print = function(){
alert("moduleA.ClassA")
}
exports.New = function(){
return new ClassA();
}
return exports;
});
define("moduleB", function(exports)
{
function ClassB(){
}
ClassB.prototype.print = function(){
alert("moduleB.ClassB")
}
exports.New = function(){
return new ClassB();
}
return exports;
});
define("moduleC", function(exports)
{
function ClassC(){
}
ClassC.prototype.print = function(){
var classA = require("moduleA").New();
classA.print();
var classB = require("moduleB").New();
classB.print();
alert("moduleC.ClassC")
}
exports.New = function(){
return new ClassC();
}
return exports;
});
var classC = require("moduleC").New();
classC.print();
</script>