Repository navigation
perf(compiler): index component hoist references once - #863
Merged
Merged
Conversation
jonkwheeler
marked this pull request as ready for review
August 26, 2026 17:09
trueadm
approved these changes
Aug 26, 2026
7 of 8 tasks
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Why
Component-heavy modules repeatedly answered the same lexical question for every component: “was this component referenced above its declaration?” Each answer sliced, sanitized, and regex-scanned a larger prefix of the module. A single indexed source pass removes that accidental quadratic work.
Clean same-machine A/B against the original base:
Changes
tsrx-component-graphoctanepatch changesetValidation
pnpm format:check(scoped check run instead)pnpm typecheck(Octane source and typetest projects run instead)pnpm test(attempted locally; unrelated browser/localStorage/timing failures accumulated before the Vitest coordinator exhausted its 4 GB heap)pnpm syncpnpm format:files:check benchmarks/tsrx-component-graph/README.md benchmarks/tsrx-component-graph/run.mjs packages/octane/src/compiler/compile.js packages/octane/tests/component-hoisting.test.ts .changeset/fast-component-hoist-scan.mdtsgo --noEmit -p packages/octane/tsconfig.jsontsgo --noEmit -p packages/octane/typetests/tsconfig.jsonnode benchmarks/bench.mjs --quick --ratios tsrx-component-graphRisk / follow-ups
Provenance
agent-authored)Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Medium Risk
Changes compiler declaration-shape classification for every component module; wrong indexing would cause TDZ crashes or lost tree-shaking, though tests and benchmark guards target that contract.
Overview
Replaces per-component prefix sanitizing and regex scans with a single module pass that records the first source offset of each top-level component name, then reuses that index when deciding whether to emit a hoisted
functionvs aconstinitializer on both client and server lowering.Behavior stays the same for strings/comments (ignored), template interpolations (still count as references), and uncommon identifier spellings (still use the historical prefix scan). New hoisting tests cover multi-name classification in both modes; the 2,400-component graph benchmark now asserts expected hoisted-declaration counts per declaration order so regressions in above-declaration detection fail the harness.
Reviewed by Cursor Bugbot for commit 5a960e4. Bugbot is set up for automated code reviews on this repo. Configure here.