dillon1000/react

Commit

[hir] Add support for directives

Previously, we would drop directives inside a component or hook but this is 
problematic with reanimated which uses `'worklet'` to mark components from 
compilation. 

This PR adds a directive to HIRFunction and ReactiveFunction and codegens the 
directive add the end. No processing is done on the directives themselves. 

Babel seems to store the directives on a BlockStatement, rather than on the 
Function but I've stored it on the Function types because we only support 
compiling functions and the spec defines directives as occuring in the initial 
statement list of a function: > A Directive Prologue is the longest sequence of 
ExpressionStatements > occurring as the initial StatementListItems or 
ModuleItems of a > FunctionBody, a ScriptBody, or a ModuleBody and where each > 
ExpressionStatement in the sequence consists entirely of a > StringLiteral token 
followed by a semicolon.
Browse files
Changed paths17 files
First-parent comparison
M compiler/packages/babel-plugin-react-forget/src/HIR/BuildHIR.ts ModifiedM compiler/packages/babel-plugin-react-forget/src/HIR/HIR.ts ModifiedM compiler/packages/babel-plugin-react-forget/src/HIR/PrintHIR.ts ModifiedM compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/BuildReactiveFunction.ts ModifiedM compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/CodegenReactiveFunction.ts ModifiedM compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/codegen-instrument-forget-gating-test.expect.md ModifiedM compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/codegen-instrument-forget-test.expect.md ModifiedA compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/function-expr-directive.expect.md AddedA compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/function-expr-directive.js AddedM compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/gating-test-export-default-function.expect.md ModifiedM compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/gating-test-export-function-and-default.expect.md ModifiedM compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/gating-test-export-function.expect.md ModifiedM compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/gating-test.expect.md ModifiedM compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/ignore-use-no-forget.expect.md ModifiedA compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/multi-directive.expect.md AddedA compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/multi-directive.js AddedM compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/use-memo-simple.expect.md Modified
Patch

Files changed

Rendering syntax-highlighted changes…