From d3bca420c049e600e176d1f1b58e17d93ec593aa Mon Sep 17 00:00:00 2001 From: Lauren Tan Date: Thu, 15 Feb 2024 17:44:44 -0500 Subject: [PATCH] Opt out react-forget-runtime from being Forgotten This caused a build error when Forget was used in an Expo app as the react-forget-runtime package was itself being compiled with Forget. This broke Metro as metro serializes modules to iifes, but the import syntax that was injected by the useMemoCachePolyfill flag was left behind In practice I don't think the runtime package needs to ever be compiled by Forget, so this PR opts out the whole file. This would also prevent builds from breaking if someone decided to use the "all" compilation mode. Test plan: Ran the expo app and verified that it now builds with no errors --- compiler/packages/react-forget-runtime/src/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/packages/react-forget-runtime/src/index.ts b/compiler/packages/react-forget-runtime/src/index.ts index 73f103bf9f..d0f0adccd2 100644 --- a/compiler/packages/react-forget-runtime/src/index.ts +++ b/compiler/packages/react-forget-runtime/src/index.ts @@ -5,6 +5,8 @@ * LICENSE file in the root directory of this source tree. */ +"use no forget"; + import invariant from "invariant"; import * as React from "react"; @@ -24,7 +26,6 @@ const $empty = Symbol.for("react.memo_cache_sentinel"); * DANGER: this hook is NEVER meant to be called directly! **/ export function unstable_useMemoCache(size: number) { - "use no forget"; return React.useState(() => { const $ = new Array(size); for (let ii = 0; ii < size; ii++) {