Add a lazy shim for ReactPerf

This prevents a circular dependency between ReactGKJSModule and ReactDOM
This commit is contained in:
Dan Abramov
2017-03-10 02:01:37 +00:00
parent a09bed0b34
commit 723b402c07
+56 -5
View File
@@ -7,13 +7,64 @@
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule ReactPerf
* @flow
*/
'use strict';
const {
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
} = require('ReactDOM');
// There is a cyclical dependency between ReactGK and
// this module. Add an indirection to delay it.
// We will remove this anyway.
module.exports = __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactPerf;
function getReactPerf() {
const {
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
} = require('ReactDOM');
return __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactPerf;
}
const LazyReactPerf = {
getLastMeasurements(...args) {
return getReactPerf().getLastMeasurements(...args);
},
getExclusive(...args) {
return getReactPerf().getExclusive(...args);
},
getInclusive(...args) {
return getReactPerf().getInclusive(...args);
},
getWasted(...args) {
return getReactPerf().getWasted(...args);
},
getOperations(...args) {
return getReactPerf().getOperations(...args);
},
printExclusive(...args) {
return getReactPerf().printExclusive(...args);
},
printInclusive(...args) {
return getReactPerf().printInclusive(...args);
},
printWasted(...args) {
return getReactPerf().printWasted(...args);
},
printOperations(...args) {
return getReactPerf().printOperations(...args);
},
start() {
return getReactPerf().start();
},
stop() {
return getReactPerf().stop();
},
isRunning(...args) {
return getReactPerf().isRunning(...args);
},
printDOM(...args) {
return getReactPerf().printDOM(...args);
},
getMeasurementsSummaryMap(...args) {
return getReactPerf().getMeasurementsSummaryMap(...args);
},
};
module.exports = LazyReactPerf;