modules weren't being cached (so doing require("foo") twice would

return two independent copies of the foo module, thus messing up
any state stored in that module)

the visible evidence of this is that commands (such as keyboard
movements) could not be found
This commit is contained in:
Kevin Dangoor 2011-01-11 23:18:23 -05:00
commit 2a2a05bab3

View file

@ -14,6 +14,7 @@ function require(module, callback) {
if (typeof module === 'string') {
var payload = require.modules[module];
var module_name = module;
if (payload == null) {
console.error('Missing module: ' + module);
}
@ -26,6 +27,8 @@ function require(module, callback) {
};
payload(require, exports, module);
payload = exports;
// cache the resulting module object for next time
require.modules[module_name] = payload;
}
if (callback) {