Skip to content

Commit 43264a6

Browse files
committed
[compiler][cleanup] Remove unused enableReactiveScopesInHIR flag
Reactive scopes in HIR has been stable for over 3 months now and is the future direction of react compiler, removing this flag to reduce implementation forks. ghstack-source-id: 65cdf63 Pull Request resolved: #30891
1 parent a03254b commit 43264a6

24 files changed

+47
-1355
lines changed

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

Lines changed: 40 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,13 @@ import {instructionReordering} from '../Optimization/InstructionReordering';
4646
import {
4747
CodegenFunction,
4848
alignObjectMethodScopes,
49-
alignReactiveScopesToBlockScopes,
5049
assertScopeInstructionsWithinScopes,
5150
assertWellFormedBreakTargets,
52-
buildReactiveBlocks,
5351
buildReactiveFunction,
5452
codegenFunction,
5553
extractScopeDeclarationsFromDestructuring,
56-
flattenReactiveLoops,
57-
flattenScopesWithHooksOrUse,
5854
inferReactiveScopeVariables,
5955
memoizeFbtAndMacroOperandsInSameScope,
60-
mergeOverlappingReactiveScopes,
6156
mergeReactiveScopesThatInvalidateTogether,
6257
promoteUsedTemporaries,
6358
propagateEarlyReturns,
@@ -300,54 +295,52 @@ function* runWithEnvironment(
300295
value: hir,
301296
});
302297

303-
if (env.config.enableReactiveScopesInHIR) {
304-
pruneUnusedLabelsHIR(hir);
305-
yield log({
306-
kind: 'hir',
307-
name: 'PruneUnusedLabelsHIR',
308-
value: hir,
309-
});
298+
pruneUnusedLabelsHIR(hir);
299+
yield log({
300+
kind: 'hir',
301+
name: 'PruneUnusedLabelsHIR',
302+
value: hir,
303+
});
310304

311-
alignReactiveScopesToBlockScopesHIR(hir);
312-
yield log({
313-
kind: 'hir',
314-
name: 'AlignReactiveScopesToBlockScopesHIR',
315-
value: hir,
316-
});
305+
alignReactiveScopesToBlockScopesHIR(hir);
306+
yield log({
307+
kind: 'hir',
308+
name: 'AlignReactiveScopesToBlockScopesHIR',
309+
value: hir,
310+
});
317311

318-
mergeOverlappingReactiveScopesHIR(hir);
319-
yield log({
320-
kind: 'hir',
321-
name: 'MergeOverlappingReactiveScopesHIR',
322-
value: hir,
323-
});
324-
assertValidBlockNesting(hir);
312+
mergeOverlappingReactiveScopesHIR(hir);
313+
yield log({
314+
kind: 'hir',
315+
name: 'MergeOverlappingReactiveScopesHIR',
316+
value: hir,
317+
});
318+
assertValidBlockNesting(hir);
325319

326-
buildReactiveScopeTerminalsHIR(hir);
327-
yield log({
328-
kind: 'hir',
329-
name: 'BuildReactiveScopeTerminalsHIR',
330-
value: hir,
331-
});
320+
buildReactiveScopeTerminalsHIR(hir);
321+
yield log({
322+
kind: 'hir',
323+
name: 'BuildReactiveScopeTerminalsHIR',
324+
value: hir,
325+
});
332326

333-
assertValidBlockNesting(hir);
327+
assertValidBlockNesting(hir);
334328

335-
flattenReactiveLoopsHIR(hir);
336-
yield log({
337-
kind: 'hir',
338-
name: 'FlattenReactiveLoopsHIR',
339-
value: hir,
340-
});
329+
flattenReactiveLoopsHIR(hir);
330+
yield log({
331+
kind: 'hir',
332+
name: 'FlattenReactiveLoopsHIR',
333+
value: hir,
334+
});
341335

342-
flattenScopesWithHooksOrUseHIR(hir);
343-
yield log({
344-
kind: 'hir',
345-
name: 'FlattenScopesWithHooksOrUseHIR',
346-
value: hir,
347-
});
348-
assertTerminalSuccessorsExist(hir);
349-
assertTerminalPredsExist(hir);
350-
}
336+
flattenScopesWithHooksOrUseHIR(hir);
337+
yield log({
338+
kind: 'hir',
339+
name: 'FlattenScopesWithHooksOrUseHIR',
340+
value: hir,
341+
});
342+
assertTerminalSuccessorsExist(hir);
343+
assertTerminalPredsExist(hir);
351344

352345
const reactiveFunction = buildReactiveFunction(hir);
353346
yield log({
@@ -364,44 +357,6 @@ function* runWithEnvironment(
364357
name: 'PruneUnusedLabels',
365358
value: reactiveFunction,
366359
});
367-
368-
if (!env.config.enableReactiveScopesInHIR) {
369-
alignReactiveScopesToBlockScopes(reactiveFunction);
370-
yield log({
371-
kind: 'reactive',
372-
name: 'AlignReactiveScopesToBlockScopes',
373-
value: reactiveFunction,
374-
});
375-
376-
mergeOverlappingReactiveScopes(reactiveFunction);
377-
yield log({
378-
kind: 'reactive',
379-
name: 'MergeOverlappingReactiveScopes',
380-
value: reactiveFunction,
381-
});
382-
383-
buildReactiveBlocks(reactiveFunction);
384-
yield log({
385-
kind: 'reactive',
386-
name: 'BuildReactiveBlocks',
387-
value: reactiveFunction,
388-
});
389-
390-
flattenReactiveLoops(reactiveFunction);
391-
yield log({
392-
kind: 'reactive',
393-
name: 'FlattenReactiveLoops',
394-
value: reactiveFunction,
395-
});
396-
397-
flattenScopesWithHooksOrUse(reactiveFunction);
398-
yield log({
399-
kind: 'reactive',
400-
name: 'FlattenScopesWithHooks',
401-
value: reactiveFunction,
402-
});
403-
}
404-
405360
assertScopeInstructionsWithinScopes(reactiveFunction);
406361

407362
propagateScopeDependencies(reactiveFunction);

compiler/packages/babel-plugin-react-compiler/src/HIR/Environment.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,6 @@ const EnvironmentConfigSchema = z.object({
222222
*/
223223
enableUseTypeAnnotations: z.boolean().default(false),
224224

225-
enableReactiveScopesInHIR: z.boolean().default(true),
226-
227225
/**
228226
* Enables inference of optional dependency chains. Without this flag
229227
* a property chain such as `props?.items?.foo` will infer as a dep on

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/align-scopes-within-nested-valueblock-in-array.expect.md

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
## Input
33

44
```javascript
5-
// @enableReactiveScopesInHIR:false
6-
75
import {Stringify, identity, makeArray, mutate} from 'shared-runtime';
86

97
/**
@@ -37,8 +35,7 @@ export const FIXTURE_ENTRYPOINT = {
3735
## Code
3836

3937
```javascript
40-
import { c as _c } from "react/compiler-runtime"; // @enableReactiveScopesInHIR:false
41-
38+
import { c as _c } from "react/compiler-runtime";
4239
import { Stringify, identity, makeArray, mutate } from "shared-runtime";
4340

4441
/**
@@ -52,11 +49,12 @@ import { Stringify, identity, makeArray, mutate } from "shared-runtime";
5249
* handles this correctly.
5350
*/
5451
function Foo(t0) {
55-
const $ = _c(4);
52+
const $ = _c(3);
5653
const { cond1, cond2 } = t0;
57-
const arr = makeArray({ a: 2 }, 2, []);
5854
let t1;
59-
if ($[0] !== cond1 || $[1] !== cond2 || $[2] !== arr) {
55+
if ($[0] !== cond1 || $[1] !== cond2) {
56+
const arr = makeArray({ a: 2 }, 2, []);
57+
6058
t1 = cond1 ? (
6159
<>
6260
<div>{identity("foo")}</div>
@@ -65,10 +63,9 @@ function Foo(t0) {
6563
) : null;
6664
$[0] = cond1;
6765
$[1] = cond2;
68-
$[2] = arr;
69-
$[3] = t1;
66+
$[2] = t1;
7067
} else {
71-
t1 = $[3];
68+
t1 = $[2];
7269
}
7370
return t1;
7471
}

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/align-scopes-within-nested-valueblock-in-array.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// @enableReactiveScopesInHIR:false
2-
31
import {Stringify, identity, makeArray, mutate} from 'shared-runtime';
42

53
/**

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/original-reactive-scopes-fork/allocating-logical-expression-instruction-scope.expect.md

Lines changed: 0 additions & 61 deletions
This file was deleted.

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/original-reactive-scopes-fork/allocating-logical-expression-instruction-scope.ts

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)