Skip to content

Commit 3e4eef7

Browse files
committed
compiler: Allow opting out of installed library check
ghstack-source-id: b161e8a Pull Request resolved: #29742
1 parent 8c3697a commit 3e4eef7

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

compiler/packages/babel-plugin-react-compiler/src/Babel/BabelPlugin.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ export default function BabelPluginReactCompiler(
3030
*/
3131
Program(prog, pass): void {
3232
let opts = parsePluginOptions(pass.opts);
33-
if (pipelineUsesReanimatedPlugin(pass.file.opts.plugins)) {
33+
if (
34+
opts.disableCheckForSupportedLibraries !== false &&
35+
pipelineUsesReanimatedPlugin(pass.file.opts.plugins)
36+
) {
3437
opts = injectReanimatedFlag(opts);
3538
}
3639
if (process.env["NODE_ENV"] === "development") {

compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,13 @@ export type PluginOptions = {
111111
ignoreUseNoForget: boolean;
112112

113113
sources?: Array<string> | ((filename: string) => boolean) | null;
114+
115+
/**
116+
* The compiler has customized support for some popular React libraries (to provide even more optimized output).
117+
* By default the compiler checks for the presence of these libraries via a `try { require(...) }` call. Set this
118+
* flag to disable the automatic check.
119+
*/
120+
disableCheckForSupportedLibraries?: boolean;
114121
};
115122

116123
const CompilationModeSchema = z.enum([

0 commit comments

Comments
 (0)