Skip to content

Commit

Permalink
Add a lazy shim for ReactPerf
Browse files Browse the repository at this point in the history
This prevents a circular dependency between ReactGKJSModule and ReactDOM
  • Loading branch information
gaearon committed Mar 10, 2017
1 parent a09bed0 commit 723b402
Showing 1 changed file with 56 additions and 5 deletions.
61 changes: 56 additions & 5 deletions scripts/rollup/forwarding/ReactPerf.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit 723b402

Please sign in to comment.