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

@Sheraff Sheraff 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-connector Bot commented Aug 31, 2026

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-05T22:30:02.355923Z 123fda5 Draft 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-cloud Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit 86dd9b4

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ✅ Succeeded 12m 16s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 1m 58s View ↗

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

@github-actions

github-actions Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

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

🟩 Patch bumps

Package Version Reason
@tanstack/nitro-v2-vite-plugin 1.155.0 → 1.155.1 Changeset
@tanstack/react-router 1.170.32 → 1.170.33 Changeset
@tanstack/router-core 1.171.27 → 1.171.28 Changeset
@tanstack/solid-router 1.170.30 → 1.170.31 Changeset
@tanstack/start-plugin-core 1.171.39 → 1.171.40 Changeset
@tanstack/vue-router 1.170.29 → 1.170.30 Changeset
@tanstack/react-start 1.168.49 → 1.168.50 Dependent
@tanstack/react-start-client 1.168.30 → 1.168.31 Dependent
@tanstack/react-start-rsc 0.1.48 → 0.1.49 Dependent
@tanstack/react-start-server 1.167.37 → 1.167.38 Dependent
@tanstack/router-cli 1.167.33 → 1.167.34 Dependent
@tanstack/router-generator 1.167.33 → 1.167.34 Dependent
@tanstack/router-plugin 1.168.35 → 1.168.36 Dependent
@tanstack/router-vite-plugin 1.167.35 → 1.167.36 Dependent
@tanstack/solid-start 1.168.47 → 1.168.48 Dependent
@tanstack/solid-start-client 1.168.29 → 1.168.30 Dependent
@tanstack/solid-start-server 1.167.36 → 1.167.37 Dependent
@tanstack/start-client-core 1.170.27 → 1.170.28 Dependent
@tanstack/start-server-core 1.169.31 → 1.169.32 Dependent
@tanstack/start-static-server-functions 1.167.32 → 1.167.33 Dependent
@tanstack/start-storage-context 1.167.29 → 1.167.30 Dependent
@tanstack/vue-start 1.168.46 → 1.168.47 Dependent
@tanstack/vue-start-client 1.167.32 → 1.167.33 Dependent
@tanstack/vue-start-server 1.167.36 → 1.167.37 Dependent

@coderabbitai

coderabbitai Bot 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 name Status Explanation
Linked Issues check ✅ Passed The 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 ✅ Passed The 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 ✅ Passed No 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 ✅ Passed The title clearly and concisely describes the main change: fixing dangling references in published router-core declarations.
Description check ✅ Passed The 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-connector chatgpt-codex-connector Bot 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 thread packages/router-core/src/load-client.ts Outdated
@Sheraff
Sheraff marked this pull request as draft August 31, 2026 20:26
@Sheraff Sheraff changed the title fix(router-core): strip internal SSR globals from declarations fix(router-core): avoid stripped SSR type reference Aug 31, 2026
@Sheraff Sheraff changed the title fix(router-core): avoid stripped SSR type reference fix(router-core): strip internal SSR globals from declarations Aug 31, 2026
nx-cloud[bot]

This comment was marked as outdated.

nx-cloud[bot]

This comment was marked as outdated.

@codspeed-hq

codspeed-hq Bot 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

Mode Benchmark BASE HEAD Efficiency
Memory mem server serialization-payload (react) 4.1 MB 6 MB -31.65%
Memory mem client mount-unmount (solid) 484.5 KB 590.6 KB -17.97%
Memory mem client navigation-churn (solid) 614.9 KB 698.3 KB -11.95%
Memory mem server request-churn (react) 697.6 KB 739.5 KB -5.66%
Memory mem server aborted-requests (react) 889.8 KB 941.6 KB -5.5%
Memory mem server server-fn-churn (solid) 336.5 KB 355.4 KB -5.3%
Memory mem client preload-churn (vue) 764.7 KB 793.8 KB -3.66%
Memory mem client unique-location-churn (solid) 791.3 KB 407.1 KB +94.38%
Memory mem server error-paths not-found (solid) 975 KB 593 KB +64.43%
Memory mem server error-paths not-found (vue) 544.4 KB 483.6 KB +12.57%
Memory mem server peak-large-page (vue) 1.1 MB 1 MB +5.41%
Memory mem server error-paths redirect (react) 312.3 KB 296.7 KB +5.29%
Memory mem client interrupted-navigations (vue) 376.5 KB 358.8 KB +4.93%
Memory mem server error-paths redirect (vue) 406 KB 390 KB +4.09%
Memory mem server serialization-payload (vue) 4.6 MB 4.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-actions Bot 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-new Bot 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

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

coderabbitai Bot commented Sep 5, 2026

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-cloud nx-cloud Bot 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 Cloud  Reject 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 main Sep 6, 2026
24 of 26 checks passed
@Sheraff
Sheraff deleted the chore/internal-ssr-window-globals branch September 6, 2026 09:00
@github-actions github-actions Bot mentioned this pull request Sep 6, 2026
Sign up for free to 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