@samitouri / QOS-React / commits / 8b6b11f703

[compiler] Remove fallback compilation pipeline dead code (#35827)

Remove dead code left behind after the removal of retryCompileFunction, enableFire, and inferEffectDependencies: - Delete ValidateNoUntransformedReferences.ts (always a no-op) - Remove CompileProgramMetadata type and retryErrors from ProgramContext - Remove 'client-no-memo' output mode - Change compileProgram return type from CompileProgramMetadata | null to void

Joseph Savona committed Feb 23, 2026 at 08:54 UTC 8b6b11f703a1f92dd2bb2e0e3b93a1836dc06de6
6 files changed +7 -198
compiler/packages/babel-plugin-react-compiler/src/Babel/BabelPlugin.ts
+1 -9
@@ -11,7 +11,6 @@ import {
11 injectReanimatedFlag,
12 pipelineUsesReanimatedPlugin,
13 } from '../Entrypoint/Reanimated';
14 -import validateNoUntransformedReferences from '../Entrypoint/ValidateNoUntransformedReferences';
14 import {CompilerError} from '..';
15
16 const ENABLE_REACT_COMPILER_TIMINGS =
@@ -64,19 +63,12 @@ export default function BabelPluginReactCompiler(
63 },
64 };
65 }
67 - const result = compileProgram(prog, {
66 + compileProgram(prog, {
67 opts,
68 filename: pass.filename ?? null,
69 comments: pass.file.ast.comments ?? [],
70 code: pass.file.code,
71 });
73 - validateNoUntransformedReferences(
74 - prog,
75 - pass.filename ?? null,
76 - opts.logger,
77 - opts.environment,
78 - result,
79 - );
72 if (ENABLE_REACT_COMPILER_TIMINGS === true) {
73 performance.mark(`${filename}:end`, {
74 detail: 'BabelPlugin:Program:end',
compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Imports.ts
+1 -6
@@ -19,7 +19,7 @@ import {getOrInsertWith} from '../Utils/utils';
19 import {ExternalFunction, isHookName} from '../HIR/Environment';
20 import {Err, Ok, Result} from '../Utils/Result';
21 import {LoggerEvent, ParsedPluginOptions} from './Options';
22 -import {BabelFn, getReactCompilerRuntimeModule} from './Program';
22 +import {getReactCompilerRuntimeModule} from './Program';
23 import {SuppressionRange} from './Suppression';
24
25 export function validateRestrictedImports(
@@ -84,11 +84,6 @@ export class ProgramContext {
84 // generated imports
85 imports: Map<string, Map<string, NonLocalImportSpecifier>> = new Map();
86
87 - /**
88 - * Metadata from compilation
89 - */
90 - retryErrors: Array<{fn: BabelFn; error: CompilerError}> = [];
91 -
87 constructor({
88 program,
89 suppressions,
compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts
-2
@@ -228,8 +228,6 @@ const CompilerOutputModeSchema = z.enum([
228 'ssr',
229 // Build optimized for the client, with auto memoization
230 'client',
231 - // Build optimized for the client without auto memo
232 - 'client-no-memo',
231 // Lint mode, the output is unused but validations should run
232 'lint',
233 ]);
compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Program.ts
+4 -11
@@ -350,9 +350,6 @@ function isFilePartOfSources(
350 return false;
351 }
352
353 -export type CompileProgramMetadata = {
354 - retryErrors: Array<{fn: BabelFn; error: CompilerError}>;
355 -};
353 /**
354 * Main entrypoint for React Compiler.
355 *
@@ -363,7 +360,7 @@ export type CompileProgramMetadata = {
360 export function compileProgram(
361 program: NodePath<t.Program>,
362 pass: CompilerPass,
366 -): CompileProgramMetadata | null {
363 +): void {
364 /**
365 * This is directly invoked by the react-compiler babel plugin, so exceptions
366 * thrown by this function will fail the babel build.
@@ -376,7 +373,7 @@ export function compileProgram(
373 * the outlined functions.
374 */
375 if (shouldSkipCompilation(program, pass)) {
379 - return null;
376 + return;
377 }
378 const restrictedImportsErr = validateRestrictedImports(
379 program,
@@ -384,7 +381,7 @@ export function compileProgram(
381 );
382 if (restrictedImportsErr) {
383 handleError(restrictedImportsErr, pass, null);
387 - return null;
384 + return;
385 }
386 /*
387 * Record lint errors and critical errors as depending on Forget's config,
@@ -478,15 +475,11 @@ export function compileProgram(
475 );
476 handleError(error, programContext, null);
477 }
481 - return null;
478 + return;
479 }
480
481 // Insert React Compiler generated functions into the Babel AST
482 applyCompiledFunctions(program, compiledFns, pass, programContext);
486 -
487 - return {
488 - retryErrors: programContext.retryErrors,
489 - };
483 }
484
485 type CompileSource = {
compiler/packages/babel-plugin-react-compiler/src/Entrypoint/ValidateNoUntransformedReferences.ts deleted
-162
@@ -1,162 +0,0 @@
1 -/**
2 - * Copyright (c) Meta Platforms, Inc. and affiliates.
3 - *
4 - * This source code is licensed under the MIT license found in the
5 - * LICENSE file in the root directory of this source tree.
6 - */
7 -
8 -import {NodePath} from '@babel/core';
9 -import * as t from '@babel/types';
10 -
11 -import {CompilerError, EnvironmentConfig, Logger} from '..';
12 -import {getOrInsertWith} from '../Utils/utils';
13 -import {GeneratedSource} from '../HIR';
14 -import {DEFAULT_EXPORT} from '../HIR/Environment';
15 -import {CompileProgramMetadata} from './Program';
16 -export default function validateNoUntransformedReferences(
17 - path: NodePath<t.Program>,
18 - filename: string | null,
19 - logger: Logger | null,
20 - env: EnvironmentConfig,
21 - compileResult: CompileProgramMetadata | null,
22 -): void {
23 - const moduleLoadChecks = new Map<
24 - string,
25 - Map<string, CheckInvalidReferenceFn>
26 - >();
27 - if (moduleLoadChecks.size > 0) {
28 - transformProgram(path, moduleLoadChecks, filename, logger, compileResult);
29 - }
30 -}
31 -
32 -type TraversalState = {
33 - shouldInvalidateScopes: boolean;
34 - program: NodePath<t.Program>;
35 - logger: Logger | null;
36 - filename: string | null;
37 - transformErrors: Array<{fn: NodePath<t.Node>; error: CompilerError}>;
38 -};
39 -type CheckInvalidReferenceFn = (
40 - paths: Array<NodePath<t.Node>>,
41 - context: TraversalState,
42 -) => void;
43 -
44 -function validateImportSpecifier(
45 - specifier: NodePath<t.ImportSpecifier>,
46 - importSpecifierChecks: Map<string, CheckInvalidReferenceFn>,
47 - state: TraversalState,
48 -): void {
49 - const imported = specifier.get('imported');
50 - const specifierName: string =
51 - imported.node.type === 'Identifier'
52 - ? imported.node.name
53 - : imported.node.value;
54 - const checkFn = importSpecifierChecks.get(specifierName);
55 - if (checkFn == null) {
56 - return;
57 - }
58 - if (state.shouldInvalidateScopes) {
59 - state.shouldInvalidateScopes = false;
60 - state.program.scope.crawl();
61 - }
62 -
63 - const local = specifier.get('local');
64 - const binding = local.scope.getBinding(local.node.name);
65 - CompilerError.invariant(binding != null, {
66 - reason: 'Expected binding to be found for import specifier',
67 - loc: local.node.loc ?? GeneratedSource,
68 - });
69 - checkFn(binding.referencePaths, state);
70 -}
71 -
72 -function validateNamespacedImport(
73 - specifier: NodePath<t.ImportNamespaceSpecifier | t.ImportDefaultSpecifier>,
74 - importSpecifierChecks: Map<string, CheckInvalidReferenceFn>,
75 - state: TraversalState,
76 -): void {
77 - if (state.shouldInvalidateScopes) {
78 - state.shouldInvalidateScopes = false;
79 - state.program.scope.crawl();
80 - }
81 - const local = specifier.get('local');
82 - const binding = local.scope.getBinding(local.node.name);
83 - const defaultCheckFn = importSpecifierChecks.get(DEFAULT_EXPORT);
84 -
85 - CompilerError.invariant(binding != null, {
86 - reason: 'Expected binding to be found for import specifier',
87 - loc: local.node.loc ?? GeneratedSource,
88 - });
89 - const filteredReferences = new Map<
90 - CheckInvalidReferenceFn,
91 - Array<NodePath<t.Node>>
92 - >();
93 - for (const reference of binding.referencePaths) {
94 - if (defaultCheckFn != null) {
95 - getOrInsertWith(filteredReferences, defaultCheckFn, () => []).push(
96 - reference,
97 - );
98 - }
99 - const parent = reference.parentPath;
100 - if (
101 - parent != null &&
102 - parent.isMemberExpression() &&
103 - parent.get('object') === reference
104 - ) {
105 - if (parent.node.computed || parent.node.property.type !== 'Identifier') {
106 - continue;
107 - }
108 - const checkFn = importSpecifierChecks.get(parent.node.property.name);
109 - if (checkFn != null) {
110 - getOrInsertWith(filteredReferences, checkFn, () => []).push(parent);
111 - }
112 - }
113 - }
114 -
115 - for (const [checkFn, references] of filteredReferences) {
116 - checkFn(references, state);
117 - }
118 -}
119 -function transformProgram(
120 - path: NodePath<t.Program>,
121 -
122 - moduleLoadChecks: Map<string, Map<string, CheckInvalidReferenceFn>>,
123 - filename: string | null,
124 - logger: Logger | null,
125 - compileResult: CompileProgramMetadata | null,
126 -): void {
127 - const traversalState: TraversalState = {
128 - shouldInvalidateScopes: true,
129 - program: path,
130 - filename,
131 - logger,
132 - transformErrors: compileResult?.retryErrors ?? [],
133 - };
134 - path.traverse({
135 - ImportDeclaration(path: NodePath<t.ImportDeclaration>) {
136 - const importSpecifierChecks = moduleLoadChecks.get(
137 - path.node.source.value,
138 - );
139 - if (importSpecifierChecks == null) {
140 - return;
141 - }
142 - const specifiers = path.get('specifiers');
143 - for (const specifier of specifiers) {
144 - if (specifier.isImportSpecifier()) {
145 - validateImportSpecifier(
146 - specifier,
147 - importSpecifierChecks,
148 - traversalState,
149 - );
150 - } else {
151 - validateNamespacedImport(
152 - specifier as NodePath<
153 - t.ImportNamespaceSpecifier | t.ImportDefaultSpecifier
154 - >,
155 - importSpecifierChecks,
156 - traversalState,
157 - );
158 - }
159 - }
160 - },
161 - });
162 -}
compiler/packages/babel-plugin-react-compiler/src/HIR/Environment.ts
+1 -8
@@ -629,9 +629,6 @@ export class Environment {
629 case 'ssr': {
630 return true;
631 }
632 - case 'client-no-memo': {
633 - return false;
634 - }
632 default: {
633 assertExhaustive(
634 this.outputMode,
@@ -648,8 +645,7 @@ export class Environment {
645 // linting also enables memoization so that we can check if manual memoization is preserved
646 return true;
647 }
651 - case 'ssr':
652 - case 'client-no-memo': {
648 + case 'ssr': {
649 return false;
650 }
651 default: {
@@ -668,9 +664,6 @@ export class Environment {
664 case 'ssr': {
665 return true;
666 }
671 - case 'client-no-memo': {
672 - return false;
673 - }
667 default: {
668 assertExhaustive(
669 this.outputMode,