Repository navigation
refactor: move compiled Router scroll restoration into Strong match tree - #2129
Merged
trueadm merged 1 commit intoOct 17, 2026
Merged
Conversation
domgan-oai
marked this pull request as ready for review
October 17, 2026 19:35
Contributor
Benchmark report🟢 No byte growth, no added work, and no timing changes beyond ±3%. Compares js-framework: 1k/10k row operationsAll 20 timed operations (20 without a verdict)
All 64 work counters are unchanged. Application bundle size (bytes)No changes across 93 measured values. Public-import reachability bundles (bytes)No changes across 123 measured values. |
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
Move the compiled Router’s scroll-restoration script from the compatibility lifecycle module into the existing Strong match tree. The script remains beneath the same immediate child of the root route, with the same SSR source, CSP nonce, permanent-static hydration range, and post-hydration removal. Keep the location predicate live because the Router object survives location changes.
This narrows the ownership tracked by #2059; pending/error handling still makes
MatchLifecycle.tsrxa compatibility dependency. No public API changes.Validation
pnpm format:check— repository-wide check not run; scoped formatting passed for all changed files.pnpm typecheck— repository-wide check not run;pnpm typecheck:filespassed for the four changed source/test files.pnpm test— repository-wide run not performed locally. A filtered install could not load an unrelated StyleX dependency from the root Vitest config; an external config mirroring the two owning projects ran Router and Router SSR: 141/141 tests across 22 files.175b85dand the candidate; compiled cases exercise accepting/declining predicates, SSR script and nonce, hydration, root identity, and navigation without script reinsertion. A transform-only negative control omitting the compiled client arm produced the expected hydration mismatch.#async-uifor direct and in-page anchors. One document request per independent flow; no page/console errors or hydration warnings.MatchLifecycle.tsrxcompatibility dependency remains.pnpm syncpassed.perf-review: scan found no candidates.CompiledScrollRestoration(packages/tanstack-router/src/compiled/Matches.tsrx:104) runs per enabled root-child render/SSR request; the production client output keeps main’s three memo slots and eager predicate, and SSR keeps the same script range. No new record shapes, DOM measurement, listeners, or scheduling. Complete emitted public JS inventory: 619 files on each build, +23 raw bytes and +20 summed per-file gzip bytes (level 9, mtime 0); this is not route transfer size. Browser latency was not benchmarked.concise-code: binding source +21/-25 lines (core runtime +0/-0); no new source module or public export; the only new file is the package changeset. Reusing ordinaryScriptOncewould use the wrong Router context; a new adapter/module would add an unnecessary owner. The location-keyed const alternative changed callback evaluation, so the local conditional preserves main’s generated behavior.Risk / follow-ups
Strong rendering requires pure application predicates; this change preserves the current generated evaluation but does not make side-effectful predicates safe. Whole-package Strong compliance, pending/error lifecycle ownership, lazy loading, and generic-renderer removal remain open under #2059.
Provenance
agent-authored)Codex task · host
com-79386Need help on this PR? Tag
@codesmith-botwith what you need.Note
Medium Risk
Touches SSR scroll-script markup and hydration parity for the compiled entry; behavior is intended to be unchanged and is heavily regression-tested, but mismatches would affect initial load scroll restoration.
Overview
Moves compiled scroll-restoration script rendering from the compatibility
MatchLifecyclemodule into the StrongMatchestree as a localCompiledScrollRestoration, still emitted under the root route’s immediate child with the same router-core script, CSP nonce, andHydrate/never()static SSR arm.The location predicate stays live on each render (
rendersScript+router.latestLocation) so function-valuedscrollRestorationoptions keep evaluating after navigations without changing router identity.Conformance coverage now runs the scroll-restoration hydration suite for both ordinary and compiled providers (nonce, accept/decline predicates, post-hydration script removal, no script on client navigation). Package status/docs and a patch changeset record that the compiled scroll script is Strong-owned; pending/error scroll lifecycle wording is dropped from the compatibility-owned list.
Reviewed by Cursor Bugbot for commit d28e75e. Bugbot is set up for automated code reviews on this repo. Configure here.