mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
[babel] Invoke gating module as a call expression
This is incredibly obvious in hindsight, but for exposure logging to work correctly we need to *call* the underlying `MobileConfig.getBool` function at the callsite – otherwise the bool is evaluated once (and only once) when the module is loaded. Tested internally and verified that in dogfooding the exposure logging was working correctly
This commit is contained in:
@@ -237,7 +237,11 @@ function buildTest(ids: {
|
||||
return t.variableDeclaration("const", [
|
||||
t.variableDeclarator(
|
||||
ids.original,
|
||||
t.conditionalExpression(testId, ids.compiled, ids.uncompiled)
|
||||
t.conditionalExpression(
|
||||
t.callExpression(testId, []),
|
||||
ids.compiled,
|
||||
ids.uncompiled
|
||||
)
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ function ErrorView_forget(error, _retry) {
|
||||
}
|
||||
return t0;
|
||||
}
|
||||
const ErrorView = isForgetEnabled ? ErrorView_forget : ErrorView_uncompiled;
|
||||
const ErrorView = isForgetEnabled() ? ErrorView_forget : ErrorView_uncompiled;
|
||||
|
||||
export default ErrorView;
|
||||
|
||||
|
||||
+2
-2
@@ -40,7 +40,7 @@ function Bar_forget(props) {
|
||||
}
|
||||
return t0;
|
||||
}
|
||||
const Bar = isForgetEnabled ? Bar_forget : Bar_uncompiled;
|
||||
const Bar = isForgetEnabled() ? Bar_forget : Bar_uncompiled;
|
||||
export default Bar;
|
||||
|
||||
function NoForget(props) {
|
||||
@@ -64,7 +64,7 @@ function Foo_forget(props) {
|
||||
}
|
||||
return t0;
|
||||
}
|
||||
const Foo = isForgetEnabled ? Foo_forget : Foo_uncompiled;
|
||||
const Foo = isForgetEnabled() ? Foo_forget : Foo_uncompiled;
|
||||
|
||||
```
|
||||
|
||||
+2
-2
@@ -40,7 +40,7 @@ function Bar_forget(props) {
|
||||
}
|
||||
return t0;
|
||||
}
|
||||
const Bar = isForgetEnabled ? Bar_forget : Bar_uncompiled;
|
||||
const Bar = isForgetEnabled() ? Bar_forget : Bar_uncompiled;
|
||||
export default Bar;
|
||||
|
||||
function NoForget(props) {
|
||||
@@ -64,7 +64,7 @@ function Foo_forget(props) {
|
||||
}
|
||||
return t0;
|
||||
}
|
||||
export const Foo = isForgetEnabled ? Foo_forget : Foo_uncompiled;
|
||||
export const Foo = isForgetEnabled() ? Foo_forget : Foo_uncompiled;
|
||||
|
||||
```
|
||||
|
||||
+2
-2
@@ -40,7 +40,7 @@ function Bar_forget(props) {
|
||||
}
|
||||
return t0;
|
||||
}
|
||||
export const Bar = isForgetEnabled ? Bar_forget : Bar_uncompiled;
|
||||
export const Bar = isForgetEnabled() ? Bar_forget : Bar_uncompiled;
|
||||
|
||||
export function NoForget(props) {
|
||||
return <Bar>{props.noForget}</Bar>;
|
||||
@@ -63,7 +63,7 @@ function Foo_forget(props) {
|
||||
}
|
||||
return t0;
|
||||
}
|
||||
export const Foo = isForgetEnabled ? Foo_forget : Foo_uncompiled;
|
||||
export const Foo = isForgetEnabled() ? Foo_forget : Foo_uncompiled;
|
||||
|
||||
```
|
||||
|
||||
@@ -40,7 +40,7 @@ function Bar_forget(props) {
|
||||
}
|
||||
return t0;
|
||||
}
|
||||
const Bar = isForgetEnabled ? Bar_forget : Bar_uncompiled;
|
||||
const Bar = isForgetEnabled() ? Bar_forget : Bar_uncompiled;
|
||||
|
||||
function NoForget(props) {
|
||||
return <Bar>{props.noForget}</Bar>;
|
||||
@@ -63,7 +63,7 @@ function Foo_forget(props) {
|
||||
}
|
||||
return t0;
|
||||
}
|
||||
const Foo = isForgetEnabled ? Foo_forget : Foo_uncompiled;
|
||||
const Foo = isForgetEnabled() ? Foo_forget : Foo_uncompiled;
|
||||
|
||||
```
|
||||
|
||||
+4
-2
@@ -34,7 +34,7 @@ function ErrorView_forget(error, _retry) {
|
||||
}
|
||||
return t0;
|
||||
}
|
||||
const ErrorView = isForgetEnabled ? ErrorView_forget : ErrorView_uncompiled;
|
||||
const ErrorView = isForgetEnabled() ? ErrorView_forget : ErrorView_uncompiled;
|
||||
function Renderer_uncompiled(props) {
|
||||
return (
|
||||
<Foo>
|
||||
@@ -73,7 +73,9 @@ function Renderer_forget(props) {
|
||||
}
|
||||
return t2;
|
||||
}
|
||||
export const Renderer = isForgetEnabled ? Renderer_forget : Renderer_uncompiled;
|
||||
export const Renderer = isForgetEnabled()
|
||||
? Renderer_forget
|
||||
: Renderer_uncompiled;
|
||||
|
||||
```
|
||||
|
||||
+2
-2
@@ -36,7 +36,7 @@ function ErrorView_forget(error, _retry) {
|
||||
}
|
||||
return t0;
|
||||
}
|
||||
const ErrorView = isForgetEnabled ? ErrorView_forget : ErrorView_uncompiled;
|
||||
const ErrorView = isForgetEnabled() ? ErrorView_forget : ErrorView_uncompiled;
|
||||
function Renderer_uncompiled(props) {
|
||||
return (
|
||||
<Foo>
|
||||
@@ -75,7 +75,7 @@ function Renderer_forget(props) {
|
||||
}
|
||||
return t2;
|
||||
}
|
||||
const Renderer = isForgetEnabled ? Renderer_forget : Renderer_uncompiled;
|
||||
const Renderer = isForgetEnabled() ? Renderer_forget : Renderer_uncompiled;
|
||||
export default Renderer;
|
||||
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user