main
js 282 lines 11 KB
Raw
1 /**
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 *
7 * @flow strict
8 */
9
10 // -----------------------------------------------------------------------------
11 // Land or remove (zero effort)
12 //
13 // Flags that can likely be deleted or landed without consequences
14 // -----------------------------------------------------------------------------
15
16 // None
17
18 // -----------------------------------------------------------------------------
19 // Killswitch
20 //
21 // Flags that exist solely to turn off a change in case it causes a regression
22 // when it rolls out to prod. We should remove these as soon as possible.
23 // -----------------------------------------------------------------------------
24
25 // Enables the browser() API exported from react-dom.
26 export const enableBrowserAPI: boolean = true;
27
28 // -----------------------------------------------------------------------------
29 // Land or remove (moderate effort)
30 //
31 // Flags that can be probably deleted or landed, but might require extra effort
32 // like migrating internal callers or performance testing.
33 // -----------------------------------------------------------------------------
34
35 // Need to remove didTimeout argument from Scheduler before landing
36 export const disableSchedulerTimeoutInWorkLoop: boolean = false;
37
38 // -----------------------------------------------------------------------------
39 // Slated for removal in the future (significant effort)
40 //
41 // These are experiments that didn't work out, and never shipped, but we can't
42 // delete from the codebase until we migrate internal callers.
43 // -----------------------------------------------------------------------------
44
45 // Add a callback property to suspense to notify which promises are currently
46 // in the update queue. This allows reporting and tracing of what is causing
47 // the user to see a loading state.
48 //
49 // Also allows hydration callbacks to fire when a dehydrated boundary gets
50 // hydrated or deleted.
51 //
52 // This will eventually be replaced by the Transition Tracing proposal.
53 export const enableSuspenseCallback: boolean = false;
54
55 // Experimental Scope support.
56 export const enableScopeAPI: boolean = false;
57
58 // Experimental Create Event Handle API.
59 export const enableCreateEventHandleAPI: boolean = false;
60
61 // Support legacy Primer support on internal FB www
62 export const enableLegacyFBSupport: boolean = false;
63
64 // -----------------------------------------------------------------------------
65 // Ongoing experiments
66 //
67 // These are features that we're either actively exploring or are reasonably
68 // likely to include in an upcoming release.
69 // -----------------------------------------------------------------------------
70
71 // Yield to the browser event loop and not just the scheduler event loop before passive effects.
72 // Fix gated tests that fail with this flag enabled before turning it back on.
73 export const enableYieldingBeforePassive: boolean = false;
74
75 // Experiment to intentionally yield less to block high framerate animations.
76 export const enableThrottledScheduling: boolean = false;
77
78 export const enableLegacyCache = __EXPERIMENTAL__;
79
80 export const enableAsyncIterableChildren = __EXPERIMENTAL__;
81
82 // Support thenables with status 'pending_weak' in Flight. A weak-pending
83 // thenable doesn't keep the stream open; if it resolves before the stream
84 // closes for other reasons, its value is emitted, otherwise its reference is
85 // left unfulfilled.
86 export const enableFlightWeakThenables = __EXPERIMENTAL__;
87
88 export const enableTaint = __EXPERIMENTAL__;
89
90 export const enableViewTransition: boolean = true;
91
92 export const enableViewTransitionParentEnterExit = __EXPERIMENTAL__;
93
94 export const enableViewTransitionForPersistenceMode: boolean = false;
95
96 export const enableGestureTransition = __EXPERIMENTAL__;
97
98 export const enableScrollEndPolyfill = __EXPERIMENTAL__;
99
100 export const enableSuspenseyImages: boolean = false;
101
102 export const enableFizzBlockingRender = __EXPERIMENTAL__; // rel="expect"
103
104 export const enableSrcObject = __EXPERIMENTAL__;
105
106 export const enableHydrationChangeEvent = __EXPERIMENTAL__;
107
108 export const enableDefaultTransitionIndicator = __EXPERIMENTAL__;
109
110 export const enableOptimisticKey = __EXPERIMENTAL__;
111
112 /**
113 * Switches Fiber creation to a simple object instead of a constructor.
114 */
115 export const enableObjectFiber: boolean = false;
116
117 export const enableTransitionTracing: boolean = false;
118
119 // FB-only usage. The new API has different semantics.
120 export const enableLegacyHidden: boolean = false;
121
122 // Enables unstable_avoidThisFallback feature in Fiber
123 export const enableSuspenseAvoidThisFallback: boolean = false;
124
125 export const enableCPUSuspense = __EXPERIMENTAL__;
126
127 // Test this at Meta before enabling.
128 export const enableNoCloningMemoCache: boolean = false;
129
130 // Test in www before enabling in open source.
131 // Enables DOM-server to stream its instruction set as data-attributes
132 // (handled with an MutationObserver) instead of inline-scripts
133 export const enableFizzExternalRuntime = __EXPERIMENTAL__;
134
135 export const alwaysThrottleRetries: boolean = true;
136
137 // Gate whether useEffectEvent uses the mutation phase (true) or before-mutation
138 // phase (false) for updating event function references.
139 export const enableEffectEventMutationPhase: boolean = true;
140
141 export const passChildrenWhenCloningPersistedNodes: boolean = false;
142
143 /**
144 * Enables an expiration time for retry lanes to avoid starvation.
145 */
146 export const enableRetryLaneExpiration: boolean = false;
147 export const retryLaneExpirationMs = 5000;
148 export const syncLaneExpirationMs = 250;
149 export const transitionLaneExpirationMs = 5000;
150
151 /**
152 * Enables a new error detection for infinite render loops from updates caused
153 * by setState or similar outside of the component owning the state.
154 */
155 export const enableInfiniteRenderLoopDetection: boolean = false;
156 /**
157 * When `enableInfiniteRenderLoopDetection` is on, forces the detection
158 * mechanism to throw instead of only warning in cases where it would
159 * otherwise downgrade to a warning.
160 */
161 export const enableInfiniteRenderLoopDetectionForceThrow: boolean = false;
162
163 export const enableConditionalUseWarning: boolean = __EXPERIMENTAL__;
164
165 export const enableFragmentRefs: boolean = true;
166 export const enableFragmentRefsScrollIntoView: boolean = true;
167 export const enableFragmentRefsInstanceHandles: boolean = true;
168 export const enableFragmentRefsTextNodes: boolean = true;
169
170 export const enableInternalInstanceMap: boolean = false;
171
172 // -----------------------------------------------------------------------------
173 // Ready for next major.
174 //
175 // Alias __NEXT_MAJOR__ to __EXPERIMENTAL__ for easier skimming.
176 // -----------------------------------------------------------------------------
177
178 // TODO: Anything that's set to `true` in this section should either be cleaned
179 // up (if it's on everywhere, including Meta and RN builds) or moved to a
180 // different section of this file.
181
182 // const __NEXT_MAJOR__ = __EXPERIMENTAL__;
183
184 /**
185 * Removes legacy style context defined using static `contextTypes` and consumed with static `childContextTypes`.
186 */
187 export const disableLegacyContext: boolean = true;
188 /**
189 * Removes legacy style context just from function components.
190 */
191 export const disableLegacyContextForFunctionComponents: boolean = true;
192
193 // Enable the moveBefore() alternative to insertBefore(). This preserves states of moves.
194 export const enableMoveBefore: boolean = false;
195
196 // Disabled caching behavior of `react/cache` in client runtimes.
197 export const disableClientCache: boolean = true;
198
199 // Warn on any usage of ReactTestRenderer
200 export const enableReactTestRendererWarning: boolean = true;
201
202 // Disables legacy mode
203 // This allows us to land breaking changes to remove legacy mode APIs in experimental builds
204 // before removing them in stable in the next Major
205 export const disableLegacyMode: boolean = true;
206
207 // -----------------------------------------------------------------------------
208 // Chopping Block
209 //
210 // Planned feature deprecations and breaking changes. Sorted roughly in order of
211 // when we plan to enable them.
212 // -----------------------------------------------------------------------------
213
214 // -----------------------------------------------------------------------------
215 // React DOM Chopping Block
216 //
217 // Similar to main Chopping Block but only flags related to React DOM. These are
218 // grouped because we will likely batch all of them into a single major release.
219 // -----------------------------------------------------------------------------
220
221 // Disable support for comment nodes as React DOM containers. Already disabled
222 // in open source, but www codebase still relies on it. Need to remove.
223 export const disableCommentsAsDOMContainers: boolean = true;
224
225 export const enableTrustedTypesIntegration: boolean = true;
226
227 // Prevent the value and checked attributes from syncing with their related
228 // DOM properties
229 export const disableInputAttributeSyncing: boolean = false;
230
231 // Disables children for <textarea> elements
232 export const disableTextareaChildren: boolean = false;
233
234 // Disables children for <textarea> elements
235 export const enableParallelTransitions: boolean = true;
236
237 // -----------------------------------------------------------------------------
238 // Debugging and DevTools
239 // -----------------------------------------------------------------------------
240
241 // Gather advanced timing metrics for Profiler subtrees.
242 export const enableProfilerTimer = __PROFILE__;
243
244 // Adds performance.measure() marks using Chrome extensions to allow formatted
245 // Component rendering tracks to show up in the Performance tab.
246 // This flag will be used for both Server Component and Client Component tracks.
247 // All calls should also be gated on enableProfilerTimer.
248 export const enableComponentPerformanceTrack: boolean = true;
249
250 // Enables annotating of React performance track events with `performanceIssue`
251 // metadata, to more prominently highlight performance issues to users
252 // (initially, an experimental feature in React Native).
253 export const enablePerformanceIssueReporting: boolean = false;
254
255 // Adds user timing marks for e.g. state updates, suspense, and work loop stuff,
256 // for an experimental timeline tool.
257 export const enableSchedulingProfiler: boolean =
258 !enableComponentPerformanceTrack && __PROFILE__;
259
260 // Record durations for commit and passive effects phases.
261 export const enableProfilerCommitHooks = __PROFILE__;
262
263 // Phase param passed to onRender callback differentiates between an "update" and a "cascading-update".
264 export const enableProfilerNestedUpdatePhase = __PROFILE__;
265
266 export const enableAsyncDebugInfo: boolean = true;
267
268 // Track which Fiber(s) schedule render work.
269 export const enableUpdaterTracking = __PROFILE__;
270
271 export const ownerStackLimit = 1e4;
272
273 // -----------------------------------------------------------------------------
274 // eslint-plugin-react-hooks
275 // -----------------------------------------------------------------------------
276 export const eprh_enableUseKeyedStateCompilerLint: boolean = false;
277 export const eprh_enableVerboseNoSetStateInEffectCompilerLint: boolean = false;
278 export const eprh_enableExhaustiveEffectDependenciesCompilerLint:
279 | 'off'
280 | 'all'
281 | 'extra-only'
282 | 'missing-only' = 'off';