Skip to content

fix(router-core): fix dangling references in published declarations - #8207

Merged
Sheraff merged 8 commits into
mainfrom
chore/internal-ssr-window-globals
Sep 6, 2026
Merged

fix(router-core): fix dangling references in published declarations#8207
Sheraff merged 8 commits into
mainfrom
chore/internal-ssr-window-globals

Conversation

@Sheraff

@SheraffSheraff commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

🎯 Changes

Fixes#8203.

Consumers using skipLibCheck: false fail to typecheck because the published DehydratedMatch.b declaration references MakeRouteMatch['__beforeLoadContext'], which is stripped by stripInternal. Mark b as internal too, so declaration generation omits the dangling reference. The field remains available to the router's serialization and hydration code.

Keep the declaration of isAbsoluteUrl, which is exported from router-core and imported by the framework bindings. Stripping it leaves another dangling reference in the package entry point. Update the React hydration fixture to explicitly include the internal context field in its serialized match type. These changes do not alter runtime behavior.

Include a router-core patch changeset.

Validation:

  • Affected lint, type, and unit checks via pnpm test:eslint, pnpm test:types, and pnpm test:unit.
  • Router-core test:build, including publint and Are the Types Wrong.
  • Manual ESM/CommonJS consumer checks and the React basic example with skipLibCheck: false on TypeScript 6 and 7.
  • Built JavaScript compared with the CodSpeed baseline (cf166d1): 90 of 92 files are byte-identical, and the remaining two differ only by the removed @internal comment.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • 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.
  • This change is docs/CI/dev-only (no release).

@chatgpt-codex-connector

chatgpt-codex-connectorBot commented Aug 31, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

ReviewStatusCommitReview trigger
📝 Code ReviewCompleted2026-09-05T22:30:02.355923Z123fda5Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@nx-cloud

nx-cloudBot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit 86dd9b4

CommandStatusDurationResult
nx affected --targets=test:eslint,test:unit,tes...✅ Succeeded12m 16sView ↗
nx run-many --target=build --exclude=examples/*...✅ Succeeded1m 58sView ↗

☁️ Nx Cloud last updated this comment at 2026-09-06 07:14:04 UTC

@github-actions

github-actionsBot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

6 package(s) bumped directly, 18 bumped as dependents.

🟩 Patch bumps

PackageVersionReason
@tanstack/nitro-v2-vite-plugin1.155.0 → 1.155.1Changeset
@tanstack/react-router1.170.32 → 1.170.33Changeset
@tanstack/router-core1.171.27 → 1.171.28Changeset
@tanstack/solid-router1.170.30 → 1.170.31Changeset
@tanstack/start-plugin-core1.171.39 → 1.171.40Changeset
@tanstack/vue-router1.170.29 → 1.170.30Changeset
@tanstack/react-start1.168.49 → 1.168.50Dependent
@tanstack/react-start-client1.168.30 → 1.168.31Dependent
@tanstack/react-start-rsc0.1.48 → 0.1.49Dependent
@tanstack/react-start-server1.167.37 → 1.167.38Dependent
@tanstack/router-cli1.167.33 → 1.167.34Dependent
@tanstack/router-generator1.167.33 → 1.167.34Dependent
@tanstack/router-plugin1.168.35 → 1.168.36Dependent
@tanstack/router-vite-plugin1.167.35 → 1.167.36Dependent
@tanstack/solid-start1.168.47 → 1.168.48Dependent
@tanstack/solid-start-client1.168.29 → 1.168.30Dependent
@tanstack/solid-start-server1.167.36 → 1.167.37Dependent
@tanstack/start-client-core1.170.27 → 1.170.28Dependent
@tanstack/start-server-core1.169.31 → 1.169.32Dependent
@tanstack/start-static-server-functions1.167.32 → 1.167.33Dependent
@tanstack/start-storage-context1.167.29 → 1.167.30Dependent
@tanstack/vue-start1.168.46 → 1.168.47Dependent
@tanstack/vue-start-client1.167.32 → 1.167.33Dependent
@tanstack/vue-start-server1.167.36 → 1.167.37Dependent

@coderabbitai

coderabbitaiBot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Team

Run ID: 053e1129-9059-4969-bcac-a8fb5dd8394f

📥 Commits

Reviewing files that changed from the base of the PR and between 76128a7 and 3111dd9.

📒 Files selected for processing (1)
  • packages/router-core/tsconfig.json

Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.


📝 Walkthrough

Walkthrough

The change marks the SSR dehydrated match context field as internal, preserves the isAbsoluteUrl declaration, and adds ESM and CommonJS declaration consumer checks. A patch changeset documents the fixes for consumers using skipLibCheck: false.

Changes

Router core declarations

Layer / File(s)Summary
Update published declaration visibility
packages/router-core/src/ssr/types.ts, packages/router-core/src/utils.ts, .changeset/cool-months-itch.md
The DehydratedMatch.b? field is marked internal. The isAbsoluteUrl declaration remains exported. The changeset records a patch release.
Compile ESM and CommonJS declaration consumers
packages/router-core/tests/declarations/*, packages/router-core/package.json, packages/router-core/tsconfig.json, packages/react-router/tests/issue-8128-context.test.tsx
Consumer files and TypeScript configurations check ESM and CommonJS declarations. The package build runs both checks. The SSR test types its dehydrated match object with DehydratedMatch.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk:⚪ Minimal · up to 86dd9

This update removes the internal dehydrated context field from published declarations while retaining runtime serialization behavior and the exported URL helper. It adds ESM and CommonJS declaration-consumer coverage, with no remaining merge-readiness risk identified.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check nameStatusExplanation
Linked Issues check✅ PassedThe PR addresses the linked issue [#8203] by marking DehydratedMatch.b as internal, preventing the published declaration from referencing the stripped __beforeLoadContext field. The added consumer che…
Out of Scope Changes check✅ PassedThe changeset, declaration tests, build configuration, React fixture update, and isAbsoluteUrl export adjustment all support the published declaration fix and its validation. No unrelated code changes…
Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 5…
Title check✅ PassedThe title clearly and concisely describes the main change: fixing dangling references in published router-core declarations.
Description check✅ PassedThe description follows the required template, explains the motivation and implementation, lists validation steps, and includes the required changeset. One non-critical checklist item remains unchecke…
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/internal-ssr-window-globals

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

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connectorchatgpt-codex-connectorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit:88621b3cd8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment threadpackages/router-core/src/load-client.ts Outdated
@Sheraff
Sheraff marked this pull request as draft August 31, 2026 20:26
@SheraffSheraff changed the title fix(router-core): strip internal SSR globals from declarationsfix(router-core): avoid stripped SSR type referenceAug 31, 2026
@SheraffSheraff changed the title fix(router-core): avoid stripped SSR type referencefix(router-core): strip internal SSR globals from declarationsAug 31, 2026
nx-cloud[bot]

This comment was marked as outdated.

nx-cloud[bot]

This comment was marked as outdated.

@codspeed-hq

codspeed-hqBot commented Aug 31, 2026

Copy link
Copy Markdown

Merging this PR will regress 7 benchmarks

⚠️Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 8 improved benchmarks
❌ 7 regressed benchmarks
✅ 159 untouched benchmarks
⏩ 54 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

ModeBenchmarkBASEHEADEfficiency
Memorymem server serialization-payload (react)4.1 MB6 MB-31.65%
Memorymem client mount-unmount (solid)484.5 KB590.6 KB-17.97%
Memorymem client navigation-churn (solid)614.9 KB698.3 KB-11.95%
Memorymem server request-churn (react)697.6 KB739.5 KB-5.66%
Memorymem server aborted-requests (react)889.8 KB941.6 KB-5.5%
Memorymem server server-fn-churn (solid)336.5 KB355.4 KB-5.3%
Memorymem client preload-churn (vue)764.7 KB793.8 KB-3.66%
Memorymem client unique-location-churn (solid)791.3 KB407.1 KB+94.38%
Memorymem server error-paths not-found (solid)975 KB593 KB+64.43%
Memorymem server error-paths not-found (vue)544.4 KB483.6 KB+12.57%
Memorymem server peak-large-page (vue)1.1 MB1 MB+5.41%
Memorymem server error-paths redirect (react)312.3 KB296.7 KB+5.29%
Memorymem client interrupted-navigations (vue)376.5 KB358.8 KB+4.93%
Memorymem server error-paths redirect (vue)406 KB390 KB+4.09%
Memorymem server serialization-payload (vue)4.6 MB4.5 MB+3.52%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing chore/internal-ssr-window-globals (86dd9b4) with main (cf166d1)

Open in CodSpeed

Footnotes

  1. 54 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@github-actions

github-actionsBot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Bundle Size Benchmarks

This pull request does not affect bundle size in any measured scenario.

@pkg-pr-new

pkg-pr-newBot commented Aug 31, 2026

Copy link
Copy Markdown
More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/@tanstack/arktype-adapter@8207

@tanstack/eslint-plugin-router

npm i https://pkg.pr.new/@tanstack/eslint-plugin-router@8207

@tanstack/eslint-plugin-start

npm i https://pkg.pr.new/@tanstack/eslint-plugin-start@8207

@tanstack/history

npm i https://pkg.pr.new/@tanstack/history@8207

@tanstack/nitro-v2-vite-plugin

npm i https://pkg.pr.new/@tanstack/nitro-v2-vite-plugin@8207

@tanstack/react-router

npm i https://pkg.pr.new/@tanstack/react-router@8207

@tanstack/react-router-devtools

npm i https://pkg.pr.new/@tanstack/react-router-devtools@8207

@tanstack/react-router-ssr-query

npm i https://pkg.pr.new/@tanstack/react-router-ssr-query@8207

@tanstack/react-start

npm i https://pkg.pr.new/@tanstack/react-start@8207

@tanstack/react-start-client

npm i https://pkg.pr.new/@tanstack/react-start-client@8207

@tanstack/react-start-rsc

npm i https://pkg.pr.new/@tanstack/react-start-rsc@8207

@tanstack/react-start-server

npm i https://pkg.pr.new/@tanstack/react-start-server@8207

@tanstack/router-cli

npm i https://pkg.pr.new/@tanstack/router-cli@8207

@tanstack/router-core

npm i https://pkg.pr.new/@tanstack/router-core@8207

@tanstack/router-devtools

npm i https://pkg.pr.new/@tanstack/router-devtools@8207

@tanstack/router-devtools-core

npm i https://pkg.pr.new/@tanstack/router-devtools-core@8207

@tanstack/router-generator

npm i https://pkg.pr.new/@tanstack/router-generator@8207

@tanstack/router-plugin

npm i https://pkg.pr.new/@tanstack/router-plugin@8207

@tanstack/router-ssr-query-core

npm i https://pkg.pr.new/@tanstack/router-ssr-query-core@8207

@tanstack/router-utils

npm i https://pkg.pr.new/@tanstack/router-utils@8207

@tanstack/router-vite-plugin

npm i https://pkg.pr.new/@tanstack/router-vite-plugin@8207

@tanstack/solid-router

npm i https://pkg.pr.new/@tanstack/solid-router@8207

@tanstack/solid-router-devtools

npm i https://pkg.pr.new/@tanstack/solid-router-devtools@8207

@tanstack/solid-router-ssr-query

npm i https://pkg.pr.new/@tanstack/solid-router-ssr-query@8207

@tanstack/solid-start

npm i https://pkg.pr.new/@tanstack/solid-start@8207

@tanstack/solid-start-client

npm i https://pkg.pr.new/@tanstack/solid-start-client@8207

@tanstack/solid-start-server

npm i https://pkg.pr.new/@tanstack/solid-start-server@8207

@tanstack/start-client-core

npm i https://pkg.pr.new/@tanstack/start-client-core@8207

@tanstack/start-fn-stubs

npm i https://pkg.pr.new/@tanstack/start-fn-stubs@8207

@tanstack/start-plugin-core

npm i https://pkg.pr.new/@tanstack/start-plugin-core@8207

@tanstack/start-server-core

npm i https://pkg.pr.new/@tanstack/start-server-core@8207

@tanstack/start-static-server-functions

npm i https://pkg.pr.new/@tanstack/start-static-server-functions@8207

@tanstack/start-storage-context

npm i https://pkg.pr.new/@tanstack/start-storage-context@8207

@tanstack/valibot-adapter

npm i https://pkg.pr.new/@tanstack/valibot-adapter@8207

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/@tanstack/virtual-file-routes@8207

@tanstack/vue-router

npm i https://pkg.pr.new/@tanstack/vue-router@8207

@tanstack/vue-router-devtools

npm i https://pkg.pr.new/@tanstack/vue-router-devtools@8207

@tanstack/vue-router-ssr-query

npm i https://pkg.pr.new/@tanstack/vue-router-ssr-query@8207

@tanstack/vue-start

npm i https://pkg.pr.new/@tanstack/vue-start@8207

@tanstack/vue-start-client

npm i https://pkg.pr.new/@tanstack/vue-start-client@8207

@tanstack/vue-start-server

npm i https://pkg.pr.new/@tanstack/vue-start-server@8207

@tanstack/zod-adapter

npm i https://pkg.pr.new/@tanstack/zod-adapter@8207

commit: 86dd9b4

@SheraffSheraff changed the title fix(router-core): strip internal SSR globals from declarationsfix(router-core): omit internal dehydrated context from declarationsSep 5, 2026
@Sheraff
Sheraff marked this pull request as ready for review September 5, 2026 22:27
@SheraffSheraff changed the title fix(router-core): omit internal dehydrated context from declarationsfix(router-core): fix dangling references in published declarationsSep 5, 2026
@coderabbitai

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@nx-cloudnx-cloudBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

At least one additional CI pipeline execution has run since the conclusion below was written and it may no longer be applicable.

Nx Cloud is proposing a fix for your failed CI:

We exclude tests/declarations/** from vitest's typecheck to fix the 6 TypeCheckError: Cannot find module '@TanStack/router-core' unhandled errors that caused test:unit to exit with code 1. The consumer.cts and consumer.mts fixtures are designed to be compiled by tsc6 -p tests/declarations/tsconfig.json (part of test:build) and rely on published package exports resolving to a built dist/ directory, a context that does not exist during test:unit.

Tip

We verified this fix by re-running @tanstack/router-core:test:unit.

diff --git a/packages/router-core/vite.config.ts b/packages/router-core/vite.config.ts
index 97859dda..d1842574 100644
--- a/packages/router-core/vite.config.ts+++ b/packages/router-core/vite.config.ts@@ -19,7 +19,7 @@ const config = defineConfig({
dir: './tests',
watch: false,
environment: 'jsdom',
- typecheck: { enabled: true },+ typecheck: { enabled: true, exclude: ['**/declarations/**'] },
// Perf tests are gated by env var and excluded from default runs.
// To run: RUN_BACKPRESSURE_PERF=1 pnpm vitest run transformStreamBackpressure
exclude:

Apply fix via Nx CloudReject fix via Nx Cloud


Or Apply changes locally with:

npx nx-cloud apply-locally vOWk-TKG9

Apply fix locally with your editor ↗View interactive diff ↗



🎓 Learn more about Self-Healing CI on nx.dev

@Sheraff
Sheraff merged commit 08eff50 into mainSep 6, 2026
24 of 26 checks passed
@Sheraff
Sheraff deleted the chore/internal-ssr-window-globals branch September 6, 2026 09:00
@github-actionsgithub-actionsBot mentioned this pull request Sep 6, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

router-core: ssr/types.d.ts references stripped @internal field, breaks tsc for consumers typechecking libs

1 participant

@Sheraff