BabelPluginReactCompiler() — react Function Reference
Architecture documentation for the BabelPluginReactCompiler() function in BabelPlugin.ts from the react codebase.
Entity Profile
Dependency Diagram
graph TD 8b3d020f_cfed_25b4_5f08_f8818958ca03["BabelPluginReactCompiler()"] f3b73a1d_8eeb_a8b2_a886_c8b8c2f58490["BabelPlugin.ts"] 8b3d020f_cfed_25b4_5f08_f8818958ca03 -->|defined in| f3b73a1d_8eeb_a8b2_a886_c8b8c2f58490 842dd25b_450e_d53a_86da_7c3b96f1f5f7["pipelineUsesReanimatedPlugin()"] 8b3d020f_cfed_25b4_5f08_f8818958ca03 -->|calls| 842dd25b_450e_d53a_86da_7c3b96f1f5f7 8c3f654e_430d_510c_2d6c_7c99e928ff65["injectReanimatedFlag()"] 8b3d020f_cfed_25b4_5f08_f8818958ca03 -->|calls| 8c3f654e_430d_510c_2d6c_7c99e928ff65 e9305144_35b9_6cfd_0fec_af0783a96987["validateNoUntransformedReferences()"] 8b3d020f_cfed_25b4_5f08_f8818958ca03 -->|calls| e9305144_35b9_6cfd_0fec_af0783a96987 style 8b3d020f_cfed_25b4_5f08_f8818958ca03 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
compiler/packages/babel-plugin-react-compiler/src/Babel/BabelPlugin.ts lines 25–112
export default function BabelPluginReactCompiler(
_babel: typeof BabelCore,
): BabelCore.PluginObj {
return {
name: 'react-forget',
visitor: {
/*
* Note: Babel does some "smart" merging of visitors across plugins, so even if A is inserted
* prior to B, if A does not have a Program visitor and B does, B will run first. We always
* want Forget to run true to source as possible.
*/
Program: {
enter(prog, pass): void {
try {
const filename = pass.filename ?? 'unknown';
if (ENABLE_REACT_COMPILER_TIMINGS === true) {
performance.mark(`${filename}:start`, {
detail: 'BabelPlugin:Program:start',
});
}
let opts = parsePluginOptions(pass.opts);
const isDev =
(typeof __DEV__ !== 'undefined' && __DEV__ === true) ||
process.env['NODE_ENV'] === 'development';
if (
opts.enableReanimatedCheck === true &&
pipelineUsesReanimatedPlugin(pass.file.opts.plugins)
) {
opts = injectReanimatedFlag(opts);
}
if (
opts.environment.enableResetCacheOnSourceFileChanges !== false &&
isDev
) {
opts = {
...opts,
environment: {
...opts.environment,
enableResetCacheOnSourceFileChanges: true,
},
};
}
const result = compileProgram(prog, {
opts,
filename: pass.filename ?? null,
comments: pass.file.ast.comments ?? [],
code: pass.file.code,
});
validateNoUntransformedReferences(
prog,
pass.filename ?? null,
opts.logger,
opts.environment,
result,
);
if (ENABLE_REACT_COMPILER_TIMINGS === true) {
performance.mark(`${filename}:end`, {
detail: 'BabelPlugin:Program:end',
});
}
} catch (e) {
if (e instanceof CompilerError) {
throw e.withPrintedMessage(pass.file.code, {eslint: false});
}
throw e;
}
},
exit(_, pass): void {
if (ENABLE_REACT_COMPILER_TIMINGS === true) {
const filename = pass.filename ?? 'unknown';
const measurement = performance.measure(filename, {
start: `${filename}:start`,
end: `${filename}:end`,
detail: 'BabelPlugin:Program',
});
if ('logger' in pass.opts && pass.opts.logger != null) {
const logger: Logger = pass.opts.logger as Logger;
logger.logEvent(filename, {
kind: 'Timing',
measurement,
});
Domain
Subdomains
Source
Frequently Asked Questions
What does BabelPluginReactCompiler() do?
BabelPluginReactCompiler() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/Babel/BabelPlugin.ts.
Where is BabelPluginReactCompiler() defined?
BabelPluginReactCompiler() is defined in compiler/packages/babel-plugin-react-compiler/src/Babel/BabelPlugin.ts at line 25.
What does BabelPluginReactCompiler() call?
BabelPluginReactCompiler() calls 3 function(s): injectReanimatedFlag, pipelineUsesReanimatedPlugin, validateNoUntransformedReferences.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free