Skip to main content

compile_program

Function compile_program 

Source
pub fn compile_program(
    file: File,
    scope: ScopeInfo,
    options: PluginOptions,
) -> CompileResult
Expand description

Main entry point for the React Compiler.

Receives a full program AST, scope information (unused for now), and resolved options. Returns a CompileResult indicating whether the AST was modified, along with any logger events.

This function implements the logic from the TS entrypoint (Program.ts):

  • shouldSkipCompilation: check for existing runtime imports
  • validateRestrictedImports: check for blocklisted imports
  • findProgramSuppressions: find eslint/flow suppression comments
  • findFunctionsToCompile: traverse program to find components and hooks
  • processFn: per-function compilation with directive and suppression handling
  • applyCompiledFunctions: replace original functions with compiled versions