From 20102ef5b149f322347d87e4c310036704ef1a50 Mon Sep 17 00:00:00 2001 From: Emily Janzer Date: Mon, 10 Jun 2019 12:00:52 -0700 Subject: [PATCH] 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 --- Libraries/TurboModule/TurboModuleRegistry.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Libraries/TurboModule/TurboModuleRegistry.js b/Libraries/TurboModule/TurboModuleRegistry.js index d0e0cd0176c..03d84d6dd75 100644 --- a/Libraries/TurboModule/TurboModuleRegistry.js +++ b/Libraries/TurboModule/TurboModuleRegistry.js @@ -17,17 +17,19 @@ import invariant from 'invariant'; const turboModuleProxy = global.__turboModuleProxy; export function get(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; }