fix(router-utils): cache a descriptor instead of the initializer AST node #8296
Open
sverrejoh(GitHub profile, opens in a new tab)wants to merge 1 commit into
main fromrefs/pull/8296/head·opened 🎯 Changes#
Alternative to #8215, which stops the same leak by cloning the node instead.
@babel/traverse keys its NodePath and Scope caches on node identity, and
the Start compiler keeps the initializer node in its module cache for the life
of the dev server, so the file's traversal graph is never collected.
Rather than cloning the node, store only what the resolvers actually read. They
follow callee, object, an identifier property, and name, never call
arguments or source positions, so the cached shape can be a small descriptor:
export type ExpressionSummary =
| { type: 'identifier'; name: string }
| { type: 'member'; object: ExpressionSummary; property: string }
| { type: 'call'; callee: ExpressionSummary }
✅ Checklist
- I have followed the steps in the Contributing guide (https://github.com/TanStack/router/blob/main/CONTRIBUTING.md).
- I have tested code changes locally with the relevant test commands, or tests do not apply to this pull request.
- I fully understand the code in this pull request, including any code generated with AI assistance.
🚀 Release Impact
- This change affects published code, and I have generated a changeset (https://github.com/changesets/changesets/blob/main/docs/adding-a-changeset.md).
- This change is docs/CI/dev-only (no release).
Summary by CodeRabbit#
- Bug Fixes
- Improved compiler cache behavior by preventing cached module information from retaining source-file parsing data.
- Preserved compiler handling for variable bindings, member access, function calls, wrapped expressions, and computed properties.
- Tests
- Expanded coverage for expression summarization and updated compiler snapshots to reflect the revised representation.
- Chores
- Published patch release updates for the affected Router and Start compiler packages.
- 1
Sign in to join this conversation.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
e136ec96-71e0-4356-b05d-0c2dfe0d7484📥 Commits
Reviewing files that changed from the base of the PR and between 9871c0625806001d6bf373524821a00303438a91 and eb9628e6405df83ad5e3b9b6194e262c7f7487f1.
📒 Files selected for processing (5)
.changeset/start-compiler-module-info-ast-retention.mdpackages/router-utils/src/compiler-helpers.tspackages/router-utils/src/index.tspackages/router-utils/tests/compiler-helpers.test.tspackages/start-plugin-core/src/start-compiler/compiler.tsIncluded review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
📝 Walkthrough
Walkthrough#
The compiler now stores compact expression summaries instead of Babel expression nodes. Router utilities expose the summary type and helper. Start compiler kind resolution consumes summarized identifiers, members, and calls.
Changes#
Expression summary retention
packages/router-utils/src/compiler-helpers.ts,packages/router-utils/src/index.ts,packages/router-utils/tests/compiler-helpers.test.ts,.changeset/start-compiler-module-info-ast-retention.mdExpressionSummaryandsummarizeExpression. Variable and default-export bindings store summarized expressions. Exports and tests cover supported expression shapes and omitted fields.packages/start-plugin-core/src/start-compiler/compiler.tsExpressionSummary, including namespace-import handling and direct-call checks.Estimated code review effort: 3 (Moderate) | ~20 minutes
Merge Risk: ⚪ Minimal · up to
f37c2This change replaces retained initializer ASTs with compact summaries while preserving supported compiler kind resolution, reducing development-server memory retention without an identified current-head merge risk.
Suggested reviewers:
schiller-manuel🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)#
✅ Passed checks (4 passed)
Full details: Docstring Coverage
Explanation
Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 4 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share