diff --git a/compiler/packages/babel-plugin-react-compiler/src/Babel/BabelPlugin.ts b/compiler/packages/babel-plugin-react-compiler/src/Babel/BabelPlugin.ts index 88731a8496594..0945f178c362d 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/Babel/BabelPlugin.ts +++ b/compiler/packages/babel-plugin-react-compiler/src/Babel/BabelPlugin.ts @@ -30,7 +30,10 @@ export default function BabelPluginReactCompiler( */ Program(prog, pass): void { let opts = parsePluginOptions(pass.opts); - if (pipelineUsesReanimatedPlugin(pass.file.opts.plugins)) { + if ( + opts.enableReanimatedCheck === true && + pipelineUsesReanimatedPlugin(pass.file.opts.plugins) + ) { opts = injectReanimatedFlag(opts); } if (process.env["NODE_ENV"] === "development") { diff --git a/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts b/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts index db305ea5c83c3..262e9b1001dee 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts +++ b/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts @@ -111,6 +111,12 @@ export type PluginOptions = { ignoreUseNoForget: boolean; sources?: Array | ((filename: string) => boolean) | null; + + /** + * The compiler has customized support for react-native-reanimated, intended as a temporary workaround. + * Set this flag (on by default) to automatically check for this library and activate the support. + */ + enableReanimatedCheck: boolean; }; const CompilationModeSchema = z.enum([ @@ -188,6 +194,7 @@ export const defaultOptions: PluginOptions = { sources: (filename) => { return filename.indexOf("node_modules") === -1; }, + enableReanimatedCheck: true, } as const; export function parsePluginOptions(obj: unknown): PluginOptions { diff --git a/compiler/packages/snap/src/compiler.ts b/compiler/packages/snap/src/compiler.ts index a664657097203..8d6671d0c286e 100644 --- a/compiler/packages/snap/src/compiler.ts +++ b/compiler/packages/snap/src/compiler.ts @@ -191,6 +191,7 @@ function makePluginOptions( eslintSuppressionRules, flowSuppressions, ignoreUseNoForget, + enableReanimatedCheck: false, }; }