Check TurboModules first in TurboModuleRegistry

Summary:
Reverse the order in which we look for modules in TurboModuleRegistry to check TurboModules first, and then fall back to legacy native modules. The main motivation for this is Venice, since requiring NativeModules.js fatals because there's no batched bridge. But we'll probably want to do this eventually anyway.

I ran a mobilelab for Marketplace home and am not seeing any significant difference in TTI.

Reviewed By: fkgozali

Differential Revision: D15703655

fbshipit-source-id: d65a4d7e09077474c30fb3938e38aee63bfa4eca
This commit is contained in:
Emily Janzer 2019-06-10 12:00:52 -07:00 коммит произвёл Facebook Github Bot
Родитель 72be568666
Коммит 20102ef5b1
1 изменённых файлов: 7 добавлений и 5 удалений

Просмотреть файл

@ -17,17 +17,19 @@ import invariant from 'invariant';
const turboModuleProxy = global.__turboModuleProxy;
export function get<T: TurboModule>(name: string): ?T {
if (turboModuleProxy != null) {
const module: ?T = turboModuleProxy(name);
if (module != null) {
return module;
}
}
// Backward compatibility layer during migration.
const legacyModule = NativeModules[name];
if (legacyModule != null) {
return ((legacyModule: any): T);
}
if (turboModuleProxy != null) {
const module: ?T = turboModuleProxy(name);
return module;
}
return null;
}