React Native (#53651)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53651

## Stack
We aim to remove +load methods from the codebase to reduce pre-main startup time and to unblock enabling startup optimizations

## Diff
Diff removes `+load` API from `RCT_EXPORT_MODULE` macro.
It introduces new parameter for `react_native_module_provider` function `eager`, which adds legacy RN modules to newly created socket `REACT_MODULE_EAGER_REGISTRATION_SOCKET`. This socket is invoked right before the RCTBridge is being initialized.

Impact: 137 static loaders are removed from the startup path

## RN
Changelog: [Internal]

Reviewed By: RSNara

Differential Revision: D81727845

fbshipit-source-id: 4904499f2e8587717b26579364ed48ffed934774
This commit is contained in:
Yury Dymov
2025-09-11 18:55:40 -07:00
committed by Facebook GitHub Bot
parent 6e011c98c1
commit a7dc5051d3
@@ -69,6 +69,7 @@ RCT_EXTERN_C_END
* will be used as the JS module name. If omitted, the JS module name will
* match the Objective-C class name.
*/
#ifndef RCT_FIT_RM_OLD_RUNTIME
#define RCT_EXPORT_MODULE(js_name) \
RCT_EXTERN void RCTRegisterModule(Class); \
+(NSString *)moduleName \
@@ -80,6 +81,17 @@ RCT_EXTERN_C_END
RCTRegisterModule(self); \
}
#else
#define RCT_EXPORT_MODULE(js_name) \
RCT_EXTERN void RCTRegisterModule(Class); \
+(NSString *)moduleName \
{ \
return @ #js_name; \
}
#endif // RCT_FIT_RM_OLD_RUNTIME
/**
* Same as RCT_EXPORT_MODULE, but uses __attribute__((constructor)) for module
* registration. Useful for registering swift classes that forbids use of load