-
Notifications
You must be signed in to change notification settings - Fork 51.1k
[compiler] Port React Compiler to Rust #36173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
435 commits
Select commit
Hold shift + click to select a range
00c8b83
[rust-compiler] Add HIR function formatting bridge for inner function…
92a03c2
[rust-compiler] Fix outlined function blank line in reactive printer
ccdb7a1
[rust-compiler] Fix StoreLocal→LoadLocal conversion in BuildReactiveF…
679bf84
[rust-compiler] Fix for-loop continue block to use update when present
f66b43a
[rust-compiler] Update reactive function plan status
2259b8b
[rust-compiler] Fix BuildReactiveFunction port fidelity issues
fd8b962
[rust-compiler] Port all reactive passes after BuildReactiveFunction
b42fa74
[rust-compiler] Remove no-op (generated) normalization from test-rust…
45b7e91
[rust-compiler] Fix identifier allocation order in PropagateEarlyReturns
295a538
[rust-compiler] Consume block IDs in dominator computation to match T…
5d5eb25
[rust-compiler] Add aggregated review summary and clean up stale revi…
e3618e9
[rust-compiler] Fix review summary to align with Rust port architectu…
c9e7ffa
[rust-compiler] Fix type inference bugs: context vars, StartMemoize d…
e3c80a2
[rust-compiler] Fix enter_ssa getIdAt unsealed fallback to match TS n…
bb67fe1
[rust-compiler] Fix saturating_sub loop bounds in MergeReactiveScopes…
ac3cbd4
[rust-compiler] Fix ConstantPropagation JS semantics: reserved words …
88bf21f
[rust-compiler] Replace String plugin options with proper enums for C…
6a35bff
[rust-compiler] Rewrite validate_no_ref_access_in_render for structur…
2d92776
[rust-compiler] Rewrite validate_no_freezing and validate_locals_not_…
ea1baa4
Revert "[rust-compiler] Fix enter_ssa getIdAt unsealed fallback to ma…
9a78bdc
Revert "[rust-compiler] Replace String plugin options with proper enu…
ff71379
[rust-compiler] Update review summary with implementation status
bdc3cbb
[rust-compiler] Convert ~55 panic!() calls to Err(CompilerDiagnostic)…
20af628
[rust-compiler] Fix review issues: propagate errors instead of .ok().…
554deeb
[rust-compiler] Add react_compiler_oxc crate — OXC frontend for React…
56250e9
[rust-compiler] Add react_compiler_swc crate — SWC frontend for React…
1aeb60b
[rust-compiler] Port CodegenReactiveFunction — final codegen pass
1ef842e
[rust-compiler] Wire CodegenReactiveFunction into pipeline
048c9be
[rust-compiler] Compare final code output in test-rust-port.ts
947f4af
[rust-compiler] Add e2e test infrastructure for all compiler frontends
ba1d0f4
[rust-compiler] Add progress output to test-e2e.ts
e4f9e9a
[rust-compiler] Fix RenameVariables scoping, ExtractScopeDeclarations…
d450cfa
[rust-compiler] Add Result support to ReactiveFunctionTransform, fix …
4035b12
[rust-compiler] Fix codegen application: comment dedup, outlined plac…
598d8e7
[rust-compiler] Update orchestrator log for codegen application, remo…
d0f42da
[rust-compiler] Fix outlined function ordering, type annotation prese…
2601907
[rust-compiler] Implement function gating codegen
1a4d44c
[rust-compiler] Port ValidatePreservedManualMemoization pass
fa6b594
[rust-compiler] Fix codegen invariants, enum passthrough, error handling
526eced
[rust-compiler] Fix code comparison failures in function discovery, r…
1a481dd
[rust-compiler] Compile outlined JSX functions through full pipeline,…
4e14cea
[rust-compiler] Fix 11 code comparison failures, add instrumentation …
c1738a4
[rust-compiler] Fix last 5 test failures: all 1717 tests now pass
0c4a252
[rust-compiler] Update orchestrator log — all 1717 pass + code tests …
577ba65
[rust-compiler] Fix all Rust compiler warnings
1ca66fd
[rust-compiler] remove outdated review docs
21cabc2
[rust-compiler] Support moduleTypeProvider in Rust compiler port
c548d7c
[rust-compiler] Port HIR visitors from TypeScript to Rust
4c8f50d
[rust-compiler] Replace local visitor copies with canonical react_com…
9411bad
[rust-compiler] Fix reactive scopes visitors to match canonical visit…
60d13da
[rust-compiler] Add env access to reactive function visitor/transform…
70beafb
[rust-compiler] Require env in reactive visitor traits, use canonical…
6440a20
[rust-compiler] Replace local visitor copies with canonical react_com…
80e02f2
[rust-compiler] Add test-rust-port.sh to compiler-verify skill
055d064
[rust-compiler] Add react_compiler_utils crate with generic DisjointSet
c179e00
[rust-compiler] Consolidate duplicated helper logic across Rust crates
43dab2c
[rust-compiler] Use visitor/transform infra in MergeReactiveScopesTha…
4d78455
[rust-compiler] Use ReactiveFunctionTransform in PropagateEarlyReturns
8aa9a2d
[rust-compiler] Use ReactiveFunctionVisitor in PruneNonEscapingScopes
ce1dae3
[rust-compiler] Use ReactiveFunctionTransform in PruneNonReactiveDepe…
812160e
[rust-compiler] Use ReactiveFunctionVisitor in PruneUnusedLvalues
70dfa72
[rust-compiler] Use ReactiveFunctionVisitor in RenameVariables
4529d49
[rust-compiler] Use ReactiveFunctionTransform in StabilizeBlockIds
42670e2
[rust-compiler] Use ReactiveFunctionVisitor for CountMemoBlockVisitor…
270963d
[rust-compiler] Remove redundant mark_predecessors call in PruneMaybe…
2d007e1
[rust-compiler] Add missing default branch error in ValidateContextVa…
08475c9
[rust-compiler] Align naming in ValidateUseMemo with TS original
a23e4ff
[rust-compiler] Align InlineIIFEs with TS original
2176f50
[rust-compiler] Fix phi processing order in EliminateRedundantPhi
65823b5
[rust-compiler] Fix TemplateLiteral undefined handling in ConstantPro…
b8f796d
[rust-compiler] Fix hook-name fallback in InferTypes resolve_property…
e890a67
[rust-compiler] Fix missing lvalue kind assignments in ValidateHooksU…
0c21a5d
[rust-compiler] Move is_props_type to shared HIR utility
d5ae445
[rust-compiler] Align InferMutationAliasingEffects with TS original
940c8bf
[rust-compiler] Remove unused parameter in DeadCodeElimination
9151ac3
[rust-compiler] Align validation passes with TS originals
a4e4a6a
[rust-compiler] Fix retainWhere dedup logic and rename in ValidateExh…
bac3935
[rust-compiler] Add missing source locations to invariant errors in R…
4e9945c
[rust-compiler] Consolidate visit_operands in MemoizeFbt to match TS
9dfe047
[rust-compiler] Add missing invariants in OutlineJsx, use mem::replac…
003df5c
[rust-compiler] Fix range accumulation bug in AlignMethodCallScopes
4553f54
[rust-compiler] Use shift_remove instead of swap_remove in PruneUnuse…
86c832a
[rust-compiler] Align BuildReactiveFunction with TS original
6c00393
[rust-compiler] Separate reason/description in AssertScopeInstruction…
ffe767b
[rust-compiler] Add missing invariant checks in PruneNonEscapingScopes
a4c0480
[rust-compiler] Use HashSet instead of HashMap<K,()> in PruneUnusedLV…
535f0f4
[rust-compiler] Align PruneHoistedContexts and ValidatePreservedManua…
7ba4e22
[rust-compiler] Add performance profiling infrastructure and conditio…
4841cac
[rust-compiler] Eliminate double AST serialization with RawValue
531be75
[rust-compiler] Remove debug_logs/ordered_log duplication
c805900
[rust-compiler] Remove debugLogs field from bridge types
880de91
[rust-compiler] Replace regex with string matching in suppressions, a…
4f1bb1d
[rust-compiler] Static base registries for ShapeRegistry and GlobalRe…
2a9a107
[rust-compiler] Fix OXC and SWC frontend compilation and wiring
473fdb3
[rust-compiler] Add --rust option to snap test command
719539b
[compiler] Normalize CompileError logger events to plain objects
9539418
[rust-compiler] Fix JSX source locations and BabelPlugin AST replacement
ea1bd85
[rust-compiler] Add identifierName to logger source locations
8e7fbd7
[rust-compiler] Fix snap test failures: FBT crashes, error formatting…
75ff31b
[rust-compiler] Fix identifierName in validation diagnostics and erro…
21ea2af
[rust-compiler] Fix exhaustive-deps hints and error formatting in cod…
b81dc57
[rust-compiler] Fix 30 snap test failures across validation, codegen,…
ea0c690
[compiler] Format TS files with prettier
dee9356
[rust-compiler] Fix remaining snap failures — 1717/1718 passing
265c7d5
[rust-compiler] Add Rust port gap analysis document
5a1f818
[rust-compiler] Fix critical gaps in transitive freeze and Unsupporte…
62cabcc
[rust-compiler] Fix error handling in inferMutationAliasingEffects to…
56fd61e
[rust-compiler] Fix function discovery to recurse into nested statements
8178b8d
[rust-compiler] Fix edge cases in nested function discovery
ba3ae49
[rust-compiler] Refactor function discovery to use AstWalker visitor
dd914d0
[rust-compiler] Add MutVisitor trait and refactor AST mutation to use…
2d31511
[rust-compiler] Fix inner function debug log flushing and todo error …
bb970d0
[rust-compiler] Fix CompilerDiagnostic::todo() to produce ErrorDetail…
27fd176
[rust-compiler] Fix function name inference to match TS parent-checki…
bed0a9a
[compiler] Update compiler-verify skill to include yarn snap --rust
9507cbc
[rust-compiler] Fix OXC frontend compilation and e2e test failures
14a056b
[rust-compiler] Fix SWC frontend optional chaining and blank line han…
699a850
[rust-compiler] Fix SWC frontend directives, parenthesization, and as…
8f51441
[rust-compiler] Fix SWC type annotations, unicode escaping, object fo…
66ac88c
[rust-compiler] Fix remaining SWC e2e failures and add test normaliza…
b533d50
[rust-compiler] Fix OXC optional chaining, object methods, comments, …
1a1b6ae
[rust-compiler] Fix OXC scope info, rest params, class decl, and test…
880a8ae
[rust-compiler] Fix remaining OXC failures: default params, TS enums,…
cd5a1ea
[compiler] Fix lint errors and add test script for Rust plugin package
9942fae
[rust-compiler] Port ValidateSourceLocations to Rust compiler
9581133
[rust-compiler] Fix ValidateSourceLocations error count discrepancy
6672405
[compiler] Fix SSR fixture pragma to use correct outputMode
efd5077
[rust-compiler] Port OptimizeForSSR pass
2d2ff35
[compiler] Fix eslint plugins to work with flattened CompileErrorDeta…
dceabf6
[rust-compiler] Move error formatting to Rust and fix JSXAttribute lo…
7b9fa07
[compiler] Remove dead JS error formatting code and @babel/code-frame…
c30ef15
[rust-compiler] Extend test-e2e with event comparison and fix bugs
b2cbb08
[rust-compiler] Fix e2e diagnostic event mismatches (123→2 failures)
8a36ba6
[rust-compiler] Use record_error(...)? for short-circuiting on Invari…
b9c4ef3
[rust-compiler] Fix last 2 e2e failures: PipelineError events and cod…
962581c
[rust-compiler] Fix e2e test formatting normalization with two-pass P…
cdd59c4
[rust-compiler] Fix OXC e2e source locations and test normalization
58400e9
[compiler] Add code/events breakdown to test-e2e.sh output
54bd672
[compiler] Fix TS2345 error in eslint-plugin-react-hooks build
ce8ea15
[compiler] Fix missing snap script in babel-plugin-react-compiler-rust
374ef56
[compiler] Add Rust CI workflow
e97ec5a
[compiler] Fix babel-plugin-react-compiler-rust CI: build snap before…
72adadf
[compiler] Fix Rust CI: build snap tool before running yarn snap --rust
8ef671f
[compiler] Increase playground test retry count
55d6ff6
[rust-compiler] Tools for internal testing
a3ab3aa
[rust-compiler] UnsupportedNode node_type population
mvitousek eb9debe
[rust-compiler] format_js_string extraction with \b/\f escapes
mvitousek 3c192bc
[rust-compiler] Bridge: sanitize lone surrogates in JSON, with escape…
mvitousek 9e31cbe
[rust-compiler] Align Array/Math built-in method shapes with TS
mvitousek d6b9735
[rust-compiler] Add visitor hooks for ClassDeclaration/ClassExpression
mvitousek 41495c9
[rust-compiler] Fix fn_type classification with DFS-last-return and c…
mvitousek e830ef2
[rust-compiler] Add node_to_scope_end for hoisting range detection
mvitousek 535fd98
[rust-compiler] Float precision — parse from extra.raw
mvitousek fbd55f4
[rust-compiler] C0-only control char escaping
mvitousek ba1a729
[rust-compiler] Hoisting decl_start conditional filtering
mvitousek 8e1cbf0
[rust-compiler] Class body JSON walking for identifier indexing
mvitousek 6d57944
[rust-compiler] PromoteUsedTemporaries recursive nested fn visiting
mvitousek d9affe7
[rust-compiler] IndexMap determinism in InferMutationAliasingRanges
mvitousek b3342e8
[rust-compiler] Scope range sync — only sync identifiers with matchin…
mvitousek c311ba0
[rust-compiler] IndexSet determinism in InferMutationAliasingEffects …
mvitousek f80900b
[rust-compiler] Dynamic function discovery traversal + FunctionExpres…
mvitousek 26d43d5
[rust-compiler] Fix synthetic IIFE scope resolution, JSX collection, …
mvitousek 5e52b48
[rust-compiler] Fix scope.ts: skip zero-width nodes in nodeToScope + …
mvitousek a29a5cd
[rust-compiler] Detect component/hook declarations in prefilter
mvitousek 1e59562
[rust-compiler] Convert assert!() to graceful error returns for fault…
mvitousek fbd8e82
[rust-compiler] Disable JSON recursion limit for deeply nested ASTs
mvitousek bbe2295
[rust-compiler] Wire cross-function UID collision avoidance through P…
mvitousek a274ac2
[rust-compiler] Use shared format_js_number in constant propagation
mvitousek df6860a
[rust-compiler] Fix UID generation indentation and simplify unwrap
mvitousek d348c56
[rust-compiler] Fix NumericLiteral precision + graceful missing ident…
mvitousek d99acce
[rust-compiler] Fix synthetic identifier resolution for match express…
mvitousek b0ed028
[compiler][rust] Fix fbt scope range sync in MemoizeFbtAndMacroOperan…
mvitousek 4b348d3
[compiler][rust] Sync identifier mutable_ranges after scope merging i…
mvitousek 6718759
[compiler][rust] Add repro fixtures for scope range sync fixes
mvitousek bf8c9fa
[compiler][rust] Add repro fixtures for bug fix commits
mvitousek a9080f1
[rust-compiler] Include type annotation references in scope data for …
mvitousek 499f39e
[compiler][rust] Fix SIGSEGV in BuildReactiveFunction by converting r…
mvitousek 30f1ba7
[rust-compiler] Fix optional chaining preserved in dependency checks
mvitousek e38f2e4
[rust-compiler] Skip type alias declarations in hoisting analysis
mvitousek 9f222ed
[compiler][rust] Handle hoisted instruction kinds in codegen for valu…
mvitousek 2ec4428
[rust-compiler] Fix hoisting to not emit DeclareContext before contro…
mvitousek 506e305
[compiler][rust] Fix naming suffix order by giving inner functions in…
mvitousek 5963faf
[rust-compiler] Fix is_binding_in_block_direct_statements to match by…
mvitousek 21ccaf2
[react-compiler-rust] Fix duplicate declaration crashes by removing h…
mvitousek 2a91267
[rust-compiler] Fix code divergences: scope position-0 guard, unused …
mvitousek 63b5469
[react-compiler-rust] Fix _temp<N> naming by merging UIDs on compilat…
mvitousek 49003e8
[react-compiler-rust] Fix numeric-literal-computed-property-assignmen…
mvitousek 7e26eb8
[react-compiler-rust] Fix unused import { c as _c } when no compiled …
mvitousek 7692af2
[rust-compiler] Node-ID resolution, OXC/SWC scope support, and contex…
mvitousek 1ed7dd7
[rust-compiler] Fix OSS test snapshots and scope.ts type error
mvitousek f29f741
[rust-compiler] Add export default enum support to ExportDefaultDecl
mvitousek 9a3f985
[rust-compiler] Handle TS cast wrappers as assignment targets (#36492)
poteto cfcbe9d
[rust-compiler] Dedup async-reassignment immutability diagnostic (#36…
poteto 4b4acc9
[rust-compiler] Match TS behavior for TypeScript this parameters (#36…
poteto 8fec1bf
[rust-compiler] Fix non-exhaustive PatternLike match in scope_resolut…
poteto 85066da
[rust-compiler] Fix off-by-one in SWC source-location conversion (#36…
poteto 09806e8
[rust-compiler] Preserve trailing and pragma comments in SWC frontend…
poteto e3ee07a
[rust-compiler] Populate loc on SWC-extracted comments (#36504)
poteto 00fe3bc
[rust-compiler] Preserve TS type annotations on SWC binding identifie…
poteto 9602762
[rust-compiler] Preserve TS type on SWC cast-wrapper expressions (#36…
poteto 0d9885c
[rust-compiler] Emit loc.column/index as UTF-16 code units in SWC fro…
poteto bc0bfba
[rust-compiler] Treat redeclared functions as one binding in SWC scop…
poteto a94a01c
[rust-compiler] Apply compiler renames to SWC module after conversion…
poteto f98a683
[rust-compiler] Inject CLI filename into PluginOptions for SWC and OX…
poteto 4f4c002
[rust-compiler] Document remaining e2e parity TODOs (#36511)
poteto f4d10fd
[rust-compiler] Bump round_trip test thread stack to 32 MiB in CI (#3…
poteto a858270
[rust-compiler] Add Rust backend support to ESLint plugin
c3a739c
[rust-compiler] Add export default function scope mapping, --dump-sco…
e49c252
[rust-compiler] Complete node-ID migration: remove position-based keying
8c3a94f
[rust-compiler] Fix remaining position-based identity lookups (Codex …
78e256c
[rust-compiler] Fix 108 WWW regressions: revert IdentifierLocIndex to…
8d3790f
[rust-compiler] Complete forward migration: IdentifierLocIndex keyed …
7f8305e
[rust-compiler] Phase 1: Set declaration_node_id in OXC/SWC, fix HirB…
eb66f46
[rust-compiler] Phase 2: Migrate hoisting + find_context to ref_node_…
ceca065
[rust-compiler] Phase 3: Remove dead position-based code
ce60bff
[rust-compiler] Fix type annotation refs dropped by node-ID migration
1934ac1
[rust-compiler] Extend IdentifierLocIndex walker for type annotations
1f0821d
[rust-compiler] Fix iteration-order sensitivity in gather_captured_co…
6f34465
[rust-compiler] Fix HoistInfo: use node_id for identifier_locs lookup
fe2b130
[rust-compiler] Stop populating reference_to_binding in OXC/SWC/outlined
5d113df
[rust-compiler] Add missing OXC AST node handlers (ImportExpression, …
397c174
[rust-compiler] Implement apply_renames for OXC frontend
75f6a2b
[rust-compiler] Add unique IDs to MutableRange for exact identity mat…
4f22df8
[rust-compiler] Populate original_node at all UnsupportedNode sites
8b880f2
[rust-compiler] Preserve explicit `predicate: null` in function-like …
poteto b7b9877
[rust-compiler] Allow Flow `TypeCastExpression` in `PatternLike` (#36…
poteto 0dc7f2e
[rust-compiler] Green the snap suite: Flow match parsing + fixture ne…
poteto be5a50f
[rust-compiler] Fix scope test: skip serializing empty node-ID maps
68a64ec
[rust-compiler] Fix scope_resolution_rename: populate node IDs in tes…
c9a79ac
[rust-compiler] Fix JSX outlining: set node_id on identifiers and use…
e8da36c
[rust-compiler] Fix UnsupportedNode codegen: handle Expression nodes …
b62e66e
[rust-compiler] Add FunctionExpression predicate, rename fixtures, up…
0e1e6b8
[rust-compiler] Preserve explicit `predicate: null` in function-like …
poteto 2b4c9bb
[rust-compiler] Flow match syntax: parse, test, and format for real
poteto b0b76d9
[rust-compiler] Add TDD fixtures for TS module-interop statements
poteto da55d8a
[rust-compiler] Tolerate unknown statement kinds at the AST boundary
poteto 3a5e2ba
[rust-compiler] Preserve TS module-interop statements in the SWC fron…
poteto a82b589
Merge branch 'main' into rust-research
poteto 0dbd252
[playground] Rehydrate logged compile error details into class instances
poteto 12f7b57
[compiler] Print non-finite numbers faithfully in DebugPrintHIR
poteto d9546c1
[rust-compiler] Resolve function-decl names from the function's own s…
poteto c47eaa3
[compiler] Capture lowercase JSX tags that shadow locals; EnterSSA to…
poteto a57184c
[rust-compiler] Drop converged entries from snap TS skip list
poteto 03397ff
[compiler] Fix multiline-comment-style lint in DebugPrintHIR
poteto 6993fae
[rust-compiler] Context-variable and capture parity with TS traverse …
poteto c83f20b
[rust-compiler] Converge catch-param fixtures: error.bug names, snaps…
poteto 90bdbc6
[rust-compiler] Fix has_local_binding to use scope_info instead of us…
49e1b18
[rust-compiler] Fix 8 pre-existing test failures: hermes-parser, snap…
b1568d6
[rust-compiler] Fix method-call-scope-merge eval snapshot for CI Node…
d9001e5
[rust-compiler] Replace toSorted() with [...arr].sort() in method-cal…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| name: React Compiler (Rust) | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| paths: | ||
| - compiler/** | ||
| - .github/workflows/compiler_rust.yml | ||
|
|
||
| permissions: {} | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.event.pull_request.number || github.run_id }} | ||
| cancel-in-progress: true | ||
|
|
||
| env: | ||
| TZ: /usr/share/zoneinfo/America/Los_Angeles | ||
| SEGMENT_DOWNLOAD_TIMEOUT_MINS: 1 | ||
|
|
||
| defaults: | ||
| run: | ||
| working-directory: compiler | ||
|
|
||
| jobs: | ||
| rust: | ||
| name: Tests | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| # --- Rust toolchain --- | ||
| - uses: dtolnay/rust-toolchain@stable | ||
|
|
||
| - name: Cache cargo registry and build | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: | | ||
| ~/.cargo/registry | ||
| ~/.cargo/git | ||
| compiler/target | ||
| key: cargo-${{ runner.os }}-${{ hashFiles('compiler/Cargo.lock') }} | ||
| restore-keys: cargo-${{ runner.os }}- | ||
|
|
||
| # --- Node (needed for test scripts) --- | ||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version-file: '.nvmrc' | ||
| cache: yarn | ||
| cache-dependency-path: compiler/yarn.lock | ||
|
|
||
| - name: Restore cached node_modules | ||
| uses: actions/cache@v4 | ||
| id: node_modules | ||
| with: | ||
| path: '**/node_modules' | ||
| key: compiler-node_modules-v6-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('compiler/yarn.lock') }} | ||
|
|
||
| - run: yarn install --frozen-lockfile | ||
| if: steps.node_modules.outputs.cache-hit != 'true' | ||
|
|
||
| # --- Build & test --- | ||
| - run: cargo check | ||
| - run: cargo build | ||
| - run: bash scripts/test-babel-ast.sh | ||
| - run: bash scripts/test-rust-port.sh | ||
| - run: yarn workspace snap run build | ||
| - run: yarn snap --rust |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| --- | ||
| name: analyze-pass-impact | ||
| description: Analyzes how a specific topic affects a group of compiler passes. Used by the /plan-update skill to parallelize research across all compiler phases. Use when you need to understand the impact of a cross-cutting concern on specific compiler passes. | ||
| model: opus | ||
| color: blue | ||
| --- | ||
|
|
||
| You are a React Compiler pass analysis specialist. Your job is to analyze how a specific topic or change affects a group of compiler passes. | ||
|
|
||
| ## Your Process | ||
|
|
||
| 1. **Read the pass documentation** for each pass in your assigned group from `compiler/packages/babel-plugin-react-compiler/docs/passes/` | ||
|
|
||
| 2. **Read the pass implementation source** in `compiler/packages/babel-plugin-react-compiler/src/`. Check these directories: | ||
| - `src/HIR/` — IR definitions, utilities, lowering | ||
| - `src/Inference/` — Effect inference (aliasing, mutation, types) | ||
| - `src/Validation/` — Validation passes | ||
| - `src/Optimization/` — Optimization passes | ||
| - `src/ReactiveScopes/` — Reactive scope analysis | ||
| - `src/Entrypoint/Pipeline.ts` — Pass ordering and invocation | ||
|
|
||
| 3. **Read the port conventions** from `compiler/docs/rust-port/rust-port-architecture.md` | ||
|
|
||
| 4. **For each pass**, analyze the topic's impact and produce a structured report | ||
|
|
||
| ## Output Format | ||
|
|
||
| For each pass in your group, report: | ||
|
|
||
| ``` | ||
| ### <Pass Name> (<pass-number>) | ||
| **Purpose**: <1-line description> | ||
| **Impact**: none | minor | moderate | significant | ||
| **Details**: <If impact is not "none", explain specifically what changes are needed> | ||
| **Key locations**: <file:line references to relevant code> | ||
| ``` | ||
|
|
||
| At the end, provide a brief summary: | ||
| ``` | ||
| ### Phase Summary | ||
| - Passes with no impact: <list> | ||
| - Passes with minor impact: <list> | ||
| - Passes with moderate impact: <list> | ||
| - Passes with significant impact: <list> | ||
| - Key insight: <1-2 sentences about the most important finding> | ||
| ``` | ||
|
|
||
| ## Guidelines | ||
|
|
||
| - Be concrete, not speculative. Reference specific code patterns you found. | ||
| - "Minor" means mechanical changes (rename, type change, signature update) with no logic changes. | ||
| - "Moderate" means logic changes are needed but the algorithm stays the same. | ||
| - "Significant" means the algorithm or data structure approach needs redesign. | ||
| - Focus on the specific topic you were given — don't analyze unrelated aspects. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| --- | ||
| name: compiler-review | ||
| description: Reviews Rust port code for port fidelity, convention compliance, and error handling. Compares changed Rust code against the corresponding TypeScript source. Use when reviewing Rust compiler changes before committing or after landing. | ||
| model: opus | ||
| color: green | ||
| --- | ||
|
|
||
| You are a React Compiler Rust port reviewer. Your job is to review Rust code in `compiler/crates/` for port fidelity, convention compliance, and correct error handling by comparing it against the original TypeScript source. | ||
|
|
||
| ## Input | ||
|
|
||
| You will receive a diff of changed Rust files. For each changed file, you must: | ||
|
|
||
| 1. **Read the architecture guide**: `compiler/docs/rust-port/rust-port-architecture.md` | ||
| 2. **Identify the corresponding TypeScript file** using the mapping below | ||
| 3. **Read the full corresponding TypeScript file** | ||
| 4. **Review the changed Rust code** against the TS source and architecture guide | ||
|
|
||
| ## Rust Crate -> TypeScript Path Mapping | ||
|
|
||
| | Rust Crate | TypeScript Path | | ||
| |---|---| | ||
| | `react_compiler_hir` | `src/HIR/` (excluding `BuildHIR.ts`, `HIRBuilder.ts`) | | ||
| | `react_compiler_lowering` | `src/HIR/BuildHIR.ts`, `src/HIR/HIRBuilder.ts` | | ||
| | `react_compiler` | `src/Babel/`, `src/Entrypoint/` | | ||
| | `react_compiler_diagnostics` | `src/CompilerError.ts` | | ||
| | `react_compiler_<name>` | `src/<Name>/` (1:1, e.g., `react_compiler_optimization` -> `src/Optimization/`) | | ||
|
|
||
| Within a crate, Rust filenames use `snake_case.rs` corresponding to `PascalCase.ts` or `camelCase.ts` in the TS source. When multiple TS files exist in the mapped folder, match by comparing exported types/functions to the Rust file's contents. | ||
|
|
||
| The TypeScript source root is `compiler/packages/babel-plugin-react-compiler/src/`. | ||
|
|
||
| ## Review Checklist | ||
|
|
||
| ### Port Fidelity | ||
| - Same high-level data flow as the TypeScript (only deviate where strictly necessary for arenas/borrow checker) | ||
| - Same grouping of logic: types, functions, struct methods should correspond to the TS file's exports | ||
| - Algorithms and control flow match the TS logic structurally | ||
| - No unnecessary additions, removals, or reorderings vs the TS | ||
|
|
||
| ### Convention Compliance | ||
| - Arena patterns: `IdentifierId`, `ScopeId`, `FunctionId`, `TypeId` used correctly (not inline data) | ||
| - `Place` is cloned, not shared by reference | ||
| - `EvaluationOrder` (not `InstructionId`) for evaluation ordering | ||
| - `InstructionId` for indexing into `HirFunction.instructions` | ||
| - `IndexMap`/`IndexSet` where iteration order matters | ||
| - `env: &mut Environment` passed separately from `func: &mut HirFunction` | ||
| - Environment fields accessed directly (not via sub-structs) for sliced borrows | ||
| - Side maps use ID-keyed `HashMap`/`HashSet` (not reference-identity maps) | ||
| - Naming: `snake_case` for functions/variables, `PascalCase` for types (matching Rust conventions) | ||
|
|
||
| ### Error Handling | ||
| - Non-null assertions (`!` in TS) -> `.unwrap()` or similar panic | ||
| - `CompilerError.invariant()`, `CompilerError.throwTodo()`, `throw` -> `Result<_, CompilerDiagnostic>` with `Err(...)` | ||
| - `pushDiagnostic()` with invariant errors -> `return Err(...)` | ||
| - `env.recordError()` or non-invariant `pushDiagnostic()` -> accumulate on `Environment` (keep as-is) | ||
|
|
||
| ## Output Format | ||
|
|
||
| Produce a numbered list of issues. For each issue: | ||
|
|
||
| ``` | ||
| N. [CATEGORY] file_path:line_number — Description of the issue | ||
| Expected: what should be there (with TS reference if applicable) | ||
| Found: what is actually there | ||
| ``` | ||
|
|
||
| Categories: `FIDELITY`, `CONVENTION`, `ERROR_HANDLING` | ||
|
|
||
| If no issues are found, report "No issues found." | ||
|
|
||
| ## Guidelines | ||
|
|
||
| - Focus only on the changed lines and their immediate context — don't review unchanged code | ||
| - Be concrete: reference specific lines in both the Rust and TS source | ||
| - Don't flag intentional deviations that are necessary for Rust's ownership model (arenas, two-phase collect/apply, `std::mem::replace`, etc.) | ||
| - Don't flag style preferences that aren't covered by the architecture guide | ||
| - Don't suggest adding comments, docs, or type annotations beyond what the TS has |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| --- | ||
| name: port-pass | ||
| description: Ports a single compiler pass from TypeScript to Rust, including crate setup, implementation, pipeline wiring, and test-fix loop until all fixtures pass. | ||
| model: opus | ||
| color: orange | ||
| --- | ||
|
|
||
| You are a Rust compiler port specialist. Your job is to port a single React Compiler pass from TypeScript to Rust, then iterate on test failures until all fixtures pass. | ||
|
|
||
| ## Input | ||
|
|
||
| You will receive: | ||
| - **Pass name**: The exact name from Pipeline.ts log entries | ||
| - **TypeScript source**: The full content of the TS file(s) to port | ||
| - **Target crate**: Name and path of the Rust crate to add code to | ||
| - **Implementation plan**: What files to create, types needed, pipeline wiring | ||
| - **Architecture guide**: Key patterns and conventions | ||
| - **Current pipeline.rs**: How existing passes are wired | ||
| - **Existing crate structure**: Files already in the target crate (if any) | ||
|
|
||
| ## Phases | ||
|
|
||
| ### Phase 1: Setup | ||
| - Understand the TypeScript source thoroughly | ||
| - Identify all types, functions, and their dependencies | ||
| - Note which types already exist in Rust (from HIR crate, etc.) | ||
|
|
||
| ### Phase 2: New Types | ||
| - Add any new types needed by this pass | ||
| - Place them in the appropriate crate (usually the target crate or `react_compiler_hir`) | ||
| - IMPORTANT: Follow the data modeling guidelines in docs/rust-port/rust-port-architecture.md for arena types (non-exhaustive types to pay extra attention to: `Identifier`, `HirFunction`, `ReactiveScope`, `Environment` etc) | ||
|
|
||
| ### Phase 3: Crate Setup (if new crate needed) | ||
| - Create `Cargo.toml` with appropriate dependencies | ||
| - Create `src/lib.rs` with module declarations | ||
| - Add the crate to the workspace `Cargo.toml` | ||
| - Add the crate as a dependency of `react_compiler` | ||
|
|
||
| ### Phase 4: Port the Pass | ||
| - Create the Rust file(s) corresponding to the TypeScript source | ||
| - Follow the translation guidelines from docs/rust-port/rust-port-architecture.md | ||
|
|
||
| Key conventions: | ||
| - **Place is Clone**: `Place` stores `IdentifierId`, making it cheap to clone | ||
| - **env separate from func**: Pass `env: &mut Environment` separately from `func: &mut HirFunction` | ||
| - **Reactive passes**: Reactive passes take `&mut ReactiveFunction` + `&Environment` or `&mut Environment` (not `&mut HirFunction`) | ||
| - **Flat environment fields**: Access env fields directly for sliced borrows | ||
| - **Two-phase collect/apply**: When you can't mutate through stored references, collect IDs first, then apply mutations | ||
| - **Ordered maps**: Use `IndexMap`/`IndexSet` where TS uses `Map`/`Set` and iteration order matters | ||
| - **Error handling**: Non-fatal errors accumulate on `env`; fatal errors return `Err` | ||
| - **Structural similarity**: Target ~85-95% correspondence with TypeScript. A developer should be able to view TS and Rust side-by-side | ||
|
|
||
| ### Phase 5: Wire Pipeline | ||
| - Add the pass call to `compiler/crates/react_compiler/src/entrypoint/pipeline.rs` | ||
| - Follow the existing pattern: call the pass function, then log with `debug_print` and `context.log_debug` | ||
| - Match the exact ordering from Pipeline.ts | ||
| - Add necessary `use` imports | ||
|
|
||
| ### Phase 6: Test-Fix Loop | ||
|
|
||
| This is the core of your work. You must achieve 0 test failures. | ||
|
|
||
| **Commands:** | ||
| - Full suite: `bash compiler/scripts/test-rust-port.sh <PassName>` | ||
| - Single fixture: `bash compiler/scripts/test-rust-port.sh <PassName> <path-to-fixture.js>` | ||
|
|
||
| **Process:** | ||
| 1. Run the full test suite | ||
| 2. If failures exist, pick ONE specific failing fixture from the output | ||
| 3. Run that single fixture in isolation to see the full diff | ||
| 4. Read the diff carefully — it shows TS output vs Rust output line by line | ||
| 5. Identify the root cause in the Rust code and fix it | ||
| 6. Re-run the single fixture to confirm the fix | ||
| 7. Re-run the full suite to check overall progress | ||
| 8. Repeat from step 2 until 0 failures | ||
|
|
||
| **Discipline:** | ||
| - Fix one fixture at a time — don't try to fix multiple issues at once | ||
| - Always verify a fix works on the single fixture before running the full suite | ||
| - Never stop early — the goal is exactly 0 failures | ||
| - If a fix causes regressions, investigate and fix those too | ||
|
|
||
| **Common failure patterns:** | ||
| - Missing match arms (Rust requires exhaustive matching) | ||
| - Wrong iteration order (need `IndexMap` instead of `HashMap`) | ||
| - Range off-by-one errors (mutable range start/end) | ||
| - Formatting diffs (debug print format doesn't match TS) | ||
| - Event mismatches (CompileError/CompileSkip events differ) | ||
| - Missing handling for edge cases the TS handles implicitly | ||
| - Identifier/scope lookups that should go through the arena | ||
|
|
||
| ## Output | ||
|
|
||
| When done, report: | ||
| - Files created/modified with brief descriptions | ||
| - Final test results (should be 0 failed) | ||
| - Any notable translation decisions made |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| --- | ||
| description: Compiler commit message convention | ||
| globs: | ||
| - compiler/**/*.js | ||
| - compiler/**/*.jsx | ||
| - compiler/**/*.ts | ||
| - compiler/**/*.tsx | ||
| - compiler/**/*.rs | ||
| - compiler/**/*.json | ||
| - compiler/**/*.md | ||
| --- | ||
|
|
||
| When committing changes in the compiler directory, follow this convention: | ||
|
|
||
| - **Rust port work** (files in `compiler/crates/` and/or `compiler/docs/rust-port`): prefix with `[rust-compiler]` | ||
| - **TS compiler work** (files in `compiler/packages/`): prefix with `[compiler]` | ||
|
|
||
| Format: | ||
| ``` | ||
| [prefix] Title | ||
| Summary of changes (1-3 sentences). | ||
| ``` | ||
|
|
||
| Use `/compiler-commit` to automatically verify and commit with the correct convention. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| --- | ||
| description: Ensure all steps in multi-step user instructions are completed | ||
| globs: | ||
| - compiler/**/* | ||
| --- | ||
|
|
||
| When the user gives multi-step instructions (e.g., "implement X, then /review, then /compiler-commit"): | ||
| - Track all steps as a checklist | ||
| - Complete ALL steps before responding | ||
| - Before declaring done, re-read the original prompt to verify nothing was missed | ||
| - If interrupted mid-way, note which steps remain |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| --- | ||
| description: Read pass documentation before modifying compiler passes | ||
| globs: | ||
| - compiler/packages/babel-plugin-react-compiler/src/**/*.ts | ||
| --- | ||
|
|
||
| Before modifying a compiler pass, read its documentation in `compiler/packages/babel-plugin-react-compiler/docs/passes/`. Pass docs explain the pass's role in the pipeline, its inputs/outputs, and key invariants. | ||
|
|
||
| Pass docs are numbered to match pipeline order (e.g., `08-inferMutationAliasingEffects.md`). Check `Pipeline.ts` if you're unsure which doc corresponds to the code you're modifying. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| --- | ||
| description: Guidelines for editing Rust port plan documents | ||
| globs: | ||
| - compiler/docs/rust-port/*.md | ||
| --- | ||
|
|
||
| When editing plan documents in `compiler/docs/rust-port/`: | ||
|
|
||
| - Use `/plan-update <doc-path> <topic>` for deep research across all compiler passes before making significant updates | ||
| - Read the architecture guide (`rust-port-architecture.md`) for context | ||
| - Reference specific pass docs from `compiler/packages/babel-plugin-react-compiler/docs/passes/` when discussing pass behavior | ||
| - Update the "Current status" line at the top of plan docs after changes | ||
| - Keep plan docs as the source of truth — if implementation diverges from the plan, update the plan |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.