Gate inlined consoleWithStackDev transpilation (#30317)
This code is getting deleted in #30313 anyway but it should've been gated all along. This code exists to basically manually transpile console.error to consoleWithStackDev because the transpiler doesn't work on `.apply` or `.bind` or the dynamic look up. We only apply the transform in DEV so we should've only done this in DEV. Otherwise these logs get silenced in prod.
Sebastian Markbåge committed
Jul 11, 2024 at 13:05 UTC
a09950ed418adb26a5e735b4ee9eca5e5282ffc7
3 files changed
+6
-6
packages/react-client/src/ReactClientConsoleConfigBrowser.js
+2
-2
@@ -65,9 +65,9 @@ export function printToConsole(
65
);
66
}
67
68
- if (methodName === 'error') {
68
+ if (methodName === 'error' && __DEV__) {
69
error.apply(console, newArgs);
70
- } else if (methodName === 'warn') {
70
+ } else if (methodName === 'warn' && __DEV__) {
71
warn.apply(console, newArgs);
72
} else {
73
// $FlowFixMe[invalid-computed-prop]
packages/react-client/src/ReactClientConsoleConfigPlain.js
+2
-2
@@ -46,9 +46,9 @@ export function printToConsole(
46
newArgs.splice(offset, 0, badgeFormat, pad + badgeName + pad);
47
}
48
49
- if (methodName === 'error') {
49
+ if (methodName === 'error' && __DEV__) {
50
error.apply(console, newArgs);
51
- } else if (methodName === 'warn') {
51
+ } else if (methodName === 'warn' && __DEV__) {
52
warn.apply(console, newArgs);
53
} else {
54
// $FlowFixMe[invalid-computed-prop]
packages/react-client/src/ReactClientConsoleConfigServer.js
+2
-2
@@ -66,9 +66,9 @@ export function printToConsole(
66
);
67
}
68
69
- if (methodName === 'error') {
69
+ if (methodName === 'error' && __DEV__) {
70
error.apply(console, newArgs);
71
- } else if (methodName === 'warn') {
71
+ } else if (methodName === 'warn' && __DEV__) {
72
warn.apply(console, newArgs);
73
} else {
74
// $FlowFixMe[invalid-computed-prop]