compiler: Allow opting out of installed library check
ghstack-source-id: eedd024d36f66a68abe43ba0f679e2d462b77505 Pull Request resolved: https://github.com/facebook/react/pull/29742
Joe Savona committed
Jun 3, 2024 at 14:20 UTC
8b677b1e6ea6cd0f7a5c3b32164c127f1fceb360
3 files changed
+12
-1
compiler/packages/babel-plugin-react-compiler/src/Babel/BabelPlugin.ts
+4
-1
@@ -30,7 +30,10 @@ export default function BabelPluginReactCompiler(
30
*/
31
Program(prog, pass): void {
32
let opts = parsePluginOptions(pass.opts);
33
- if (pipelineUsesReanimatedPlugin(pass.file.opts.plugins)) {
33
+ if (
34
+ opts.enableReanimatedCheck === true &&
35
+ pipelineUsesReanimatedPlugin(pass.file.opts.plugins)
36
+ ) {
37
opts = injectReanimatedFlag(opts);
38
}
39
if (process.env["NODE_ENV"] === "development") {
compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts
+7
@@ -111,6 +111,12 @@ export type PluginOptions = {
111
ignoreUseNoForget: boolean;
112
113
sources?: Array<string> | ((filename: string) => boolean) | null;
114
+
115
+ /**
116
+ * The compiler has customized support for react-native-reanimated, intended as a temporary workaround.
117
+ * Set this flag (on by default) to automatically check for this library and activate the support.
118
+ */
119
+ enableReanimatedCheck: boolean;
120
};
121
122
const CompilationModeSchema = z.enum([
@@ -188,6 +194,7 @@ export const defaultOptions: PluginOptions = {
194
sources: (filename) => {
195
return filename.indexOf("node_modules") === -1;
196
},
197
+ enableReanimatedCheck: true,
198
} as const;
199
200
export function parsePluginOptions(obj: unknown): PluginOptions {
compiler/packages/snap/src/compiler.ts
+1
@@ -191,6 +191,7 @@ function makePluginOptions(
191
eslintSuppressionRules,
192
flowSuppressions,
193
ignoreUseNoForget,
194
+ enableReanimatedCheck: false,
195
};
196
}
197