Codemod Internal Unit Tests and Remove Require Fallback

Summary:
MessageQueue no longer falls back to require. To do this we need to register all the modules in our internal unit tests. I did this codemod manually.

This is a bit unfortunate boilerplate but there are very few of these modules outside of unit tests. This boilerplate is only a hassle for these test files.

public

Reviewed By: spicyj

Differential Revision: D2736397

fb-gh-sync-id: 59fa4c4e75c538f3577bc9693b93e1b7c4d4d233
This commit is contained in:
Sebastian Markbage 2015-12-10 23:15:38 -08:00 committed by facebook-github-bot-0
parent b78b8f6cab
commit ae912a83d7

View File

@ -159,20 +159,11 @@ class MessageQueue {
console.log('N->JS : ' + module + '.' + method + '(' + JSON.stringify(args) + ')');
}
var moduleMethods = this._callableModules[module];
if (!moduleMethods) {
// TODO: Register all the remaining test modules and make this an invariant. #9317773
// Fallback to require temporarily. A follow up diff will clean up the remaining
// modules and make this an invariant.
console.warn('Module is not registered:', module);
moduleMethods = require(module);
/*
invariant(
!!moduleMethods,
'Module %s is not a registered callable module.',
module
);
*/
}
invariant(
!!moduleMethods,
'Module %s is not a registered callable module.',
module
);
moduleMethods[method].apply(moduleMethods, args);
BridgeProfiling.profileEnd();
}