mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
de6aa10bdd
Summary:
Right now we use `BatchedBridge.registerLazyCallableModule` for all JS modules except for `HMRClient`, which uses `registerCallableModule` instead (takes the module itself instead of a function that returns it). I'm standardizing on `registerLazyCallableModule` so that it will be easier to swap out the implementation later for bridgeless mode.
The only reason I could think why we wouldn't want to do this is if we're relying on some side effect of `require('HMRClient')` when setting up JS, but there don't seem to be any side effects in that module that I can see.
Changelog: [Internal]
Reviewed By: rickhanlonii
Differential Revision: D18798870
fbshipit-source-id: a5c950bdbfd998bb12e4843ee28ece08a26c84bf
62 lines
2.0 KiB
JavaScript
62 lines
2.0 KiB
JavaScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @flow strict-local
|
|
* @format
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
/**
|
|
* We don't set up the batched bridge in bridgeless mode. Once we've migrated
|
|
* everything over to bridgeless we can just delete this file.
|
|
*/
|
|
if (!global.RN$Bridgeless) {
|
|
/**
|
|
* Set up the BatchedBridge. This must be done after the other steps in
|
|
* InitializeCore to ensure that the JS environment has been initialized.
|
|
* You can use this module directly, or just require InitializeCore.
|
|
*/
|
|
const BatchedBridge = require('../BatchedBridge/BatchedBridge');
|
|
BatchedBridge.registerLazyCallableModule('Systrace', () =>
|
|
require('../Performance/Systrace'),
|
|
);
|
|
BatchedBridge.registerLazyCallableModule('JSTimers', () =>
|
|
require('./Timers/JSTimers'),
|
|
);
|
|
BatchedBridge.registerLazyCallableModule('HeapCapture', () =>
|
|
require('../HeapCapture/HeapCapture'),
|
|
);
|
|
BatchedBridge.registerLazyCallableModule('SamplingProfiler', () =>
|
|
require('../Performance/SamplingProfiler'),
|
|
);
|
|
BatchedBridge.registerLazyCallableModule('RCTLog', () =>
|
|
require('../Utilities/RCTLog'),
|
|
);
|
|
BatchedBridge.registerLazyCallableModule('RCTDeviceEventEmitter', () =>
|
|
require('../EventEmitter/RCTDeviceEventEmitter'),
|
|
);
|
|
BatchedBridge.registerLazyCallableModule('RCTNativeAppEventEmitter', () =>
|
|
require('../EventEmitter/RCTNativeAppEventEmitter'),
|
|
);
|
|
BatchedBridge.registerLazyCallableModule('GlobalPerformanceLogger', () =>
|
|
require('../Utilities/GlobalPerformanceLogger'),
|
|
);
|
|
BatchedBridge.registerLazyCallableModule('JSDevSupportModule', () =>
|
|
require('../Utilities/JSDevSupportModule'),
|
|
);
|
|
|
|
if (__DEV__ && !global.__RCTProfileIsProfiling) {
|
|
BatchedBridge.registerLazyCallableModule('HMRClient', () =>
|
|
require('../Utilities/HMRClient'),
|
|
);
|
|
} else {
|
|
BatchedBridge.registerLazyCallableModule('HMRClient', () =>
|
|
require('../Utilities/HMRClientProdShim'),
|
|
);
|
|
}
|
|
}
|