Skip to content

Commit 9f89dbf

Browse files
committed
[compiler] Simplify FunctionExpression node
Rather than storing the entire babel node, store only the required information which is the node type. This will be useful for when we synthesize new functions that don't have a corresponding babel node. [ghstack-poisoned]
1 parent 47069f0 commit 9f89dbf

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3270,7 +3270,7 @@ function lowerFunctionToValue(
32703270
return {
32713271
kind: 'FunctionExpression',
32723272
name,
3273-
expr: expr.node,
3273+
type: expr.node.type,
32743274
loc: exprLoc,
32753275
loweredFunc,
32763276
};

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,10 +1076,10 @@ export type FunctionExpression = {
10761076
kind: 'FunctionExpression';
10771077
name: string | null;
10781078
loweredFunc: LoweredFunction;
1079-
expr:
1080-
| t.ArrowFunctionExpression
1081-
| t.FunctionExpression
1082-
| t.FunctionDeclaration;
1079+
type:
1080+
| 'ArrowFunctionExpression'
1081+
| 'FunctionExpression'
1082+
| 'FunctionDeclaration';
10831083
loc: SourceLocation;
10841084
};
10851085

compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/CodegenReactiveFunction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1997,7 +1997,7 @@ function codegenInstructionValue(
19971997
),
19981998
reactiveFunction,
19991999
).unwrap();
2000-
if (instrValue.expr.type === 'ArrowFunctionExpression') {
2000+
if (instrValue.type === 'ArrowFunctionExpression') {
20012001
let body: t.BlockStatement | t.Expression = fn.body;
20022002
if (body.body.length === 1 && loweredFunc.directives.length == 0) {
20032003
const stmt = body.body[0]!;

0 commit comments

Comments
 (0)