Skip to content

Commit 7aae556

Browse files
cipolleschimeta-codesync[bot]
authored andcommitted
Remove RCT_EXPORT_MODULE from Core modules (#54288)
Summary: Pull Request resolved: #54288 This change remove the usage of RCT_EXPORT_MODULE from all the classes of React Native Core. This allow us to remove the +load method that runs at initialization of React Native and that can slow down the start of React Native itself. All the classes are still registered due to the [`RCTBridge`'s `getCoreModuleClasses`](https://github.com/facebook/react-native/blob/main/packages/react-native/React/Base/RCTBridge.mm#L46) which manually lists all the classes that got modified. --- ## TODO There are some classes that should be loaded using the respective plugins. Currently, the OSS implementation only uses the [CoreModulePlugin](https://github.com/facebook/react-native/blob/main/packages/react-native/React/CoreModules/CoreModulesPlugins.mm#L19), but we should add the lookup also in these others plugins: - RCTBlobPlugins.mm - RCTImagePlugins.mm - RCTNetworkPlugins.mm - RCTSettingsPlugins.mm - RCTLinkingPlugins.mm - RCTVibrationPlugins.mm - RCTAnimationPlugins.mm - RCTPushNotificationPlugins.mm (if the import is available. The push notification module is not included by default) ## Changelog: [Internal] - Remove RCT_EXPORT_MODULE from RN Core Modules Reviewed By: javache Differential Revision: D85580258 fbshipit-source-id: 6df6002afdcd2d7344a4a9fb2674a9f34c7abc1e
1 parent fe18f1f commit 7aae556

62 files changed

Lines changed: 249 additions & 62 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/react-native/Libraries/Blob/RCTBlobManager.mm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ @implementation RCTBlobManager {
4242
dispatch_queue_t _processingQueue;
4343
}
4444

45-
RCT_EXPORT_MODULE(BlobModule)
45+
+ (NSString *)moduleName
46+
{
47+
return @"BlobModule";
48+
}
4649

4750
@synthesize bridge = _bridge;
4851
@synthesize moduleRegistry = _moduleRegistry;

packages/react-native/Libraries/Blob/RCTFileReaderModule.mm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ @interface RCTFileReaderModule () <NativeFileReaderModuleSpec>
2020

2121
@implementation RCTFileReaderModule
2222

23-
RCT_EXPORT_MODULE(FileReaderModule)
23+
+ (NSString *)moduleName
24+
{
25+
return @"FileReaderModule";
26+
}
2427

2528
@synthesize moduleRegistry = _moduleRegistry;
2629

packages/react-native/Libraries/Image/RCTBundleAssetImageLoader.mm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ @interface RCTBundleAssetImageLoader () <RCTTurboModule>
2020

2121
@implementation RCTBundleAssetImageLoader
2222

23-
RCT_EXPORT_MODULE()
23+
+ (NSString *)moduleName
24+
{
25+
return @"BundleAssetImageLoader";
26+
}
2427

2528
- (BOOL)canLoadImageURL:(NSURL *)requestURL
2629
{

packages/react-native/Libraries/Image/RCTGIFImageDecoder.mm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ @interface RCTGIFImageDecoder () <RCTTurboModule>
2020

2121
@implementation RCTGIFImageDecoder
2222

23-
RCT_EXPORT_MODULE()
23+
+ (NSString *)moduleName
24+
{
25+
return @"GIFImageDecoder";
26+
}
2427

2528
- (BOOL)canDecodeImageData:(NSData *)imageData
2629
{

packages/react-native/Libraries/Image/RCTImageEditingManager.mm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ @interface RCTImageEditingManager () <NativeImageEditorSpec>
2424

2525
@implementation RCTImageEditingManager
2626

27-
RCT_EXPORT_MODULE()
27+
+ (NSString *)moduleName
28+
{
29+
return @"ImageEditingManager";
30+
}
2831

2932
@synthesize moduleRegistry = _moduleRegistry;
3033

packages/react-native/Libraries/Image/RCTImageLoader.mm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,10 @@ @implementation RCTImageLoader {
9292
@synthesize maxConcurrentDecodingTasks = _maxConcurrentDecodingTasks;
9393
@synthesize maxConcurrentDecodingBytes = _maxConcurrentDecodingBytes;
9494

95-
RCT_EXPORT_MODULE()
95+
+ (NSString *)moduleName
96+
{
97+
return @"RCTImageLoader";
98+
}
9699

97100
- (instancetype)init
98101
{

packages/react-native/Libraries/Image/RCTImageStoreManager.mm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ @implementation RCTImageStoreManager {
3232

3333
@synthesize methodQueue = _methodQueue;
3434

35-
RCT_EXPORT_MODULE()
35+
+ (NSString *)moduleName
36+
{
37+
return @"ImageStoreManager";
38+
}
3639

3740
+ (BOOL)requiresMainQueueSetup
3841
{

packages/react-native/Libraries/Image/RCTImageViewManager.mm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@
2020

2121
@implementation RCTImageViewManager
2222

23-
RCT_EXPORT_MODULE()
23+
+ (NSString *)moduleName
24+
{
25+
return @"ImageViewManager";
26+
}
2427

2528
- (RCTShadowView *)shadowView
2629
{

packages/react-native/Libraries/Image/RCTLocalAssetImageLoader.mm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ @interface RCTLocalAssetImageLoader () <RCTTurboModule>
2020

2121
@implementation RCTLocalAssetImageLoader
2222

23-
RCT_EXPORT_MODULE()
23+
+ (NSString *)moduleName
24+
{
25+
return @"LocalAssetImageLoader";
26+
}
2427

2528
- (BOOL)canLoadImageURL:(NSURL *)requestURL
2629
{

packages/react-native/Libraries/LinkingIOS/RCTLinkingManager.mm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ @interface RCTLinkingManager () <NativeLinkingManagerSpec>
2727

2828
@implementation RCTLinkingManager
2929

30-
RCT_EXPORT_MODULE()
30+
+ (NSString *)moduleName
31+
{
32+
return @"LinkingManager";
33+
}
3134

3235
- (dispatch_queue_t)methodQueue
3336
{

0 commit comments

Comments
 (0)