@samitouri / QOS-React / commits / 059760548f

Flag to remove www console forks (#32058)

Let's remove these

Ricky committed Jan 15, 2025 at 08:19 UTC 059760548feb9615fc651469d6380613a667b2c8
10 files changed +28 -2
packages/shared/ReactFeatureFlags.js
+2
@@ -261,3 +261,5 @@ export const enableUpdaterTracking = __PROFILE__;
261
262 // Internal only.
263 export const enableDO_NOT_USE_disableStrictPassiveEffect = false;
264 +
265 +export const enableRemoveConsolePatches = true;
packages/shared/forks/ReactFeatureFlags.native-fb-dynamic.js
+1
@@ -27,3 +27,4 @@ export const enableFabricCompleteRootInCommitPhase = __VARIANT__;
27 export const enableSiblingPrerendering = __VARIANT__;
28 export const enableUseResourceEffectHook = __VARIANT__;
29 export const enableOwnerStacks = __VARIANT__;
30 +export const enableRemoveConsolePatches = __VARIANT__;
packages/shared/forks/ReactFeatureFlags.native-fb.js
+1
@@ -29,6 +29,7 @@ export const {
29 passChildrenWhenCloningPersistedNodes,
30 enableSiblingPrerendering,
31 enableOwnerStacks,
32 + enableRemoveConsolePatches,
33 } = dynamicFlags;
34
35 // The rest of the flags are static for better dead code elimination.
packages/shared/forks/ReactFeatureFlags.native-oss.js
+1
@@ -78,6 +78,7 @@ export const enableProfilerTimer = __PROFILE__;
78 export const enableProfilerCommitHooks = __PROFILE__;
79 export const enableProfilerNestedUpdatePhase = __PROFILE__;
80 export const enableUpdaterTracking = __PROFILE__;
81 +export const enableRemoveConsolePatches = false;
82
83 // Flow magic to verify the exports of this file match the original version.
84 ((((null: any): ExportsType): FeatureFlagsType): ExportsType);
packages/shared/forks/ReactFeatureFlags.test-renderer.js
+1
@@ -88,6 +88,7 @@ export const disableDefaultPropsExceptForClasses = true;
88
89 export const enableObjectFiber = false;
90 export const enableOwnerStacks = false;
91 +export const enableRemoveConsolePatches = true;
92
93 // Flow magic to verify the exports of this file match the original version.
94 ((((null: any): ExportsType): FeatureFlagsType): ExportsType);
packages/shared/forks/ReactFeatureFlags.test-renderer.native-fb.js
+1
@@ -68,6 +68,7 @@ export const enableHydrationLaneScheduling = true;
68 export const enableYieldingBeforePassive = false;
69 export const enableThrottledScheduling = false;
70 export const enableViewTransition = false;
71 +export const enableRemoveConsolePatches = false;
72
73 // Flow magic to verify the exports of this file match the original version.
74 ((((null: any): ExportsType): FeatureFlagsType): ExportsType);
packages/shared/forks/ReactFeatureFlags.test-renderer.www.js
+1
@@ -83,6 +83,7 @@ export const enableYieldingBeforePassive = false;
83
84 export const enableThrottledScheduling = false;
85 export const enableViewTransition = false;
86 +export const enableRemoveConsolePatches = false;
87
88 // Flow magic to verify the exports of this file match the original version.
89 ((((null: any): ExportsType): FeatureFlagsType): ExportsType);
packages/shared/forks/ReactFeatureFlags.www-dynamic.js
+1
@@ -37,6 +37,7 @@ export const enableInfiniteRenderLoopDetection = __VARIANT__;
37 export const enableSiblingPrerendering = __VARIANT__;
38
39 export const enableUseResourceEffectHook = __VARIANT__;
40 +export const enableRemoveConsolePatches = __VARIANT__;
41
42 // TODO: These flags are hard-coded to the default values used in open source.
43 // Update the tests so that they pass in either mode, then set these
packages/shared/forks/ReactFeatureFlags.www.js
+1
@@ -36,6 +36,7 @@ export const {
36 syncLaneExpirationMs,
37 transitionLaneExpirationMs,
38 enableOwnerStacks,
39 + enableRemoveConsolePatches,
40 } = dynamicFeatureFlags;
41
42 // On WWW, __EXPERIMENTAL__ is used for a new modern build.
packages/shared/forks/consoleWithStackDev.www.js
+18 -2
@@ -5,18 +5,27 @@
5 * LICENSE file in the root directory of this source tree.
6 */
7
8 +const {enableRemoveConsolePatches} = require('shared/ReactFeatureFlags');
9 +
10 // This refers to a WWW module.
11 const warningWWW = require('warning');
12
13 let suppressWarning = false;
14 export function setSuppressWarning(newSuppressWarning) {
15 + if (enableRemoveConsolePatches) {
16 + return;
17 + }
18 if (__DEV__) {
19 suppressWarning = newSuppressWarning;
20 }
21 }
22
23 export function warn(format, ...args) {
19 - if (__DEV__) {
24 + if (enableRemoveConsolePatches) {
25 + if (__DEV__) {
26 + console['warn'](format, ...args);
27 + }
28 + } else if (__DEV__) {
29 if (!suppressWarning) {
30 printWarning('warn', format, args);
31 }
@@ -24,7 +33,11 @@ export function warn(format, ...args) {
33 }
34
35 export function error(format, ...args) {
27 - if (__DEV__) {
36 + if (enableRemoveConsolePatches) {
37 + if (__DEV__) {
38 + console['error'](format, ...args);
39 + }
40 + } else if (__DEV__) {
41 if (!suppressWarning) {
42 printWarning('error', format, args);
43 }
@@ -32,6 +45,9 @@ export function error(format, ...args) {
45 }
46
47 function printWarning(level, format, args) {
48 + if (enableRemoveConsolePatches) {
49 + return;
50 + }
51 if (__DEV__) {
52 const React = require('react');
53 const ReactSharedInternals =