@samitouri / QOS-React / commits / b956024f3d

Fix Jest tests

ghstack-source-id: e2507b7285bb52ee02d2cece35aa16eb0bc0baa5 Pull Request resolved: https://github.com/facebook/react-forget/pull/2963

Joe Savona committed May 13, 2024 at 14:09 UTC b956024f3d10d82a3f1b9a5186727d8275f42ab4
2 files changed +13 -4
compiler/packages/babel-plugin-react-compiler/scripts/jest/makeTransform.ts
+9 -1
@@ -176,7 +176,15 @@ function ReactForgetFunctionTransform() {
176 }
177 }
178
179 - const compiled = compile(fn, forgetOptions, "Other", null, null);
179 + const compiled = compile(
180 + fn,
181 + forgetOptions,
182 + "Other",
183 + "_c",
184 + null,
185 + null,
186 + null
187 + );
188 compiledFns.add(compiled);
189
190 const fun = t.functionDeclaration(
compiler/packages/babel-plugin-react-compiler/scripts/jest/setupEnvE2E.js
+4 -3
@@ -9,7 +9,8 @@ const ReactCompilerRuntime = require("react/compiler-runtime");
9
10 /*
11 * Our e2e babel transform currently only compiles functions, not programs.
12 - * As a result, our e2e transpiled code does not contain an import for `useMemoCache`
13 - * This is a hack.
12 + * As a result, our e2e transpiled code does not contain an import for the
13 + * memo cache function. As a temporary hack, we add a `_c` global, which is
14 + * the name that is used for the import by default.
15 */
15 -globalThis.useMemoCache = ReactCompilerRuntime.c;
16 +globalThis._c = ReactCompilerRuntime.c;