Skip to content

Commit 723b402

Browse files
committed
Add a lazy shim for ReactPerf
This prevents a circular dependency between ReactGKJSModule and ReactDOM
1 parent a09bed0 commit 723b402

1 file changed

Lines changed: 56 additions & 5 deletions

File tree

scripts/rollup/forwarding/ReactPerf.js

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,64 @@
77
* of patent rights can be found in the PATENTS file in the same directory.
88
*
99
* @providesModule ReactPerf
10-
* @flow
1110
*/
1211

1312
'use strict';
1413

15-
const {
16-
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
17-
} = require('ReactDOM');
14+
// There is a cyclical dependency between ReactGK and
15+
// this module. Add an indirection to delay it.
16+
// We will remove this anyway.
1817

19-
module.exports = __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactPerf;
18+
function getReactPerf() {
19+
const {
20+
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
21+
} = require('ReactDOM');
22+
return __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactPerf;
23+
}
24+
25+
const LazyReactPerf = {
26+
getLastMeasurements(...args) {
27+
return getReactPerf().getLastMeasurements(...args);
28+
},
29+
getExclusive(...args) {
30+
return getReactPerf().getExclusive(...args);
31+
},
32+
getInclusive(...args) {
33+
return getReactPerf().getInclusive(...args);
34+
},
35+
getWasted(...args) {
36+
return getReactPerf().getWasted(...args);
37+
},
38+
getOperations(...args) {
39+
return getReactPerf().getOperations(...args);
40+
},
41+
printExclusive(...args) {
42+
return getReactPerf().printExclusive(...args);
43+
},
44+
printInclusive(...args) {
45+
return getReactPerf().printInclusive(...args);
46+
},
47+
printWasted(...args) {
48+
return getReactPerf().printWasted(...args);
49+
},
50+
printOperations(...args) {
51+
return getReactPerf().printOperations(...args);
52+
},
53+
start() {
54+
return getReactPerf().start();
55+
},
56+
stop() {
57+
return getReactPerf().stop();
58+
},
59+
isRunning(...args) {
60+
return getReactPerf().isRunning(...args);
61+
},
62+
printDOM(...args) {
63+
return getReactPerf().printDOM(...args);
64+
},
65+
getMeasurementsSummaryMap(...args) {
66+
return getReactPerf().getMeasurementsSummaryMap(...args);
67+
},
68+
};
69+
70+
module.exports = LazyReactPerf;

0 commit comments

Comments
 (0)