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:
parent
bcf8ad2457
commit
2a2a05bab3
1 changed files with 3 additions and 0 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue