I think your definition function should look like this, so that "m" is properly scoped:
function(moduleList) {
var arr = [], i; // declare i!!!!
function def(m) {
define(m.guid, function() {
return {
container : m.container,
configuration : m.configuration,
moduleId : m.id
}
});
}
for (i = 0, l = moduleList.length; i < l; i++) {
var m = moduleList[i];
def(m);
arr[i] = m;
}
}
In your code, the same variable "m" is shared among all those module callbacks. By introducing another function (and another scope), you make sure that each callback has its own copy.