[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:
Lauren Tan
2023-03-31 11:15:51 -04:00
parent 5beecef28f
commit 46a9d40914
8 changed files with 20 additions and 14 deletions
+5 -1
View File
@@ -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
)
),
]);
}
@@ -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;
@@ -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;
```
@@ -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;
```
@@ -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;
```
@@ -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;
```
@@ -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;
```