File tree Expand file tree Collapse file tree 4 files changed +41
-1
lines changed
scripts/rollup/shims/rollup Expand file tree Collapse file tree 4 files changed +41
-1
lines changed Original file line number Diff line number Diff line change 77 * @flow
88 */
99
10+ import invariant from 'fbjs/lib/invariant' ;
11+
1012import typeof * as FeatureFlagsType from 'shared/ReactFeatureFlags' ;
1113import typeof * as CSFeatureFlagsType from './ReactNativeCSFeatureFlags' ;
1214
@@ -21,6 +23,10 @@ export const enableMutatingReconciler = false;
2123export const enableNoopReconciler = false ;
2224export const enablePersistentReconciler = true ;
2325
26+ export function addUserTimingListener ( ) {
27+ invariant ( false , 'Not implemented.' ) ;
28+ }
29+
2430// Flow magic to verify the exports of this file match the original version.
2531// eslint-disable-next-line no-unused-vars
2632type Check < _X , Y : _X , X : Y = _X > = null ;
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import * as ReactInstanceMap from 'shared/ReactInstanceMap';
1313import * as ReactFiberErrorLogger
1414 from 'react-reconciler/src/ReactFiberErrorLogger' ;
1515import ReactErrorUtils from 'shared/ReactErrorUtils' ;
16+ import { addUserTimingListener } from 'shared/ReactFeatureFlags' ;
1617
1718import ReactDOM from './ReactDOM' ;
1819import * as ReactBrowserEventEmitter from '../events/ReactBrowserEventEmitter' ;
@@ -31,6 +32,8 @@ Object.assign(
3132 ReactInstanceMap,
3233 // Used by www msite:
3334 TapEventPlugin,
35+ // Perf experiment
36+ addUserTimingListener,
3437 } ,
3538) ;
3639
Original file line number Diff line number Diff line change 77 * @flow
88 */
99
10+ import invariant from 'fbjs/lib/invariant' ;
11+
1012export const enableAsyncSubtreeAPI = true ;
1113export const enableAsyncSchedulingByDefaultInReactDOM = false ;
1214// Exports React.Fragment
@@ -21,3 +23,7 @@ export const enableMutatingReconciler = true;
2123export const enableNoopReconciler = false ;
2224// Experimental persistent mode (CS):
2325export const enablePersistentReconciler = false ;
26+
27+ export function addUserTimingListener ( ) {
28+ invariant ( false , 'Not implemented.' ) ;
29+ }
Original file line number Diff line number Diff line change @@ -16,13 +16,38 @@ export const {
1616 enableAsyncSchedulingByDefaultInReactDOM,
1717 enableReactFragment,
1818 enableCreateRoot,
19- enableUserTimingAPI,
2019 // Reconciler flags
2120 enableMutatingReconciler,
2221 enableNoopReconciler,
2322 enablePersistentReconciler,
2423} = require ( 'ReactFeatureFlags' ) ;
2524
25+ export let enableUserTimingAPI = __DEV__ ;
26+
27+ let refCount = 0 ;
28+ export function addUserTimingListener ( ) {
29+ if ( __DEV__ ) {
30+ // Noop.
31+ return ( ) => { } ;
32+ }
33+ refCount ++ ;
34+ updateFlagOutsideOfReactCallStack ( ) ;
35+ return ( ) => {
36+ refCount -- ;
37+ updateFlagOutsideOfReactCallStack ( ) ;
38+ } ;
39+ }
40+
41+ let timeout = null ;
42+ function updateFlagOutsideOfReactCallStack ( ) {
43+ if ( ! timeout ) {
44+ timeout = setTimeout ( ( ) => {
45+ timeout = null ;
46+ enableUserTimingAPI = refCount > 0 ;
47+ } ) ;
48+ }
49+ }
50+
2651// Flow magic to verify the exports of this file match the original version.
2752// eslint-disable-next-line no-unused-vars
2853type Check < _X , Y : _X , X : Y = _X > = null ;
You can’t perform that action at this time.
0 commit comments