⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

Conversation

@schiller-manuel
Copy link
Contributor

@schiller-manuel schiller-manuel commented Jan 11, 2026

Summary

Fixes #5738 - Server-side modules incorrectly bundled into the client

Starting with @tanstack/[email protected], server-side modules (like the cookie module from Clerk SDK) were incorrectly being bundled into the client bundle, causing runtime errors like:

SyntaxError: The requested module '/node_modules/cookie/dist/index.js' does not provide an export named 'parse'

Root Cause

The crawlFrameworkPkgs function finds packages that have @tanstack/react-start or @tanstack/start-client-core as peerDependencies and was adding them to optimizeDeps.exclude. This caused third-party packages (like Clerk SDK, tanstack-themes) to not be pre-bundled properly, leading to server-side module leakage.

The Fix

Remove exclude: crawlFrameworkPkgsResult.optimizeDeps.exclude from the client environment's optimizeDeps configuration. This allows Vite to properly pre-bundle third-party packages and their dependencies.

Testing

Verified the fix works with:

  • Clerk SDK (@clerk/tanstack-react-start) - No more cookie module errors
  • tanstack-themes (@tanstack-themes/react) - Works correctly
  • TanStack Form (@tanstack/react-form) - No more use-sync-external-store errors

All unit and type tests pass.

Summary by CodeRabbit

  • Chores
    • Updated dependency optimization configuration in the build process. Framework-related packages will now be processed during dependency optimization, potentially affecting how dependencies are pre-bundled in client builds.

✏️ Tip: You can customize this high-level summary in your review settings.

…xclude

This fixes issue #5738 where server-side modules (like the `cookie` module
from Clerk SDK) were incorrectly being bundled into the client.

The `crawlFrameworkPkgs` function finds packages that have `@tanstack/react-start`
or `@tanstack/start-client-core` as peer dependencies and was adding them to
`optimizeDeps.exclude`. This prevented Vite from pre-bundling these packages,
causing their server-side dependencies to leak into the client bundle as native
ESM imports, which failed at runtime with errors like:

  SyntaxError: The requested module 'cookie' does not provide an export named 'parse'

By removing this automatic exclusion, Vite will now properly pre-bundle
third-party packages and their dependencies, ensuring correct module resolution.

fixes #5738
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 11, 2026

📝 Walkthrough

Walkthrough

Removed the optimizeDeps.exclude property from the client Vite configuration in the TanStack Start plugin core, changing how dependencies are pre-bundled during client builds and addressing incorrect server-side module inclusion issues.

Changes

Cohort / File(s) Summary
Client Dependency Optimization Configuration
packages/start-plugin-core/src/plugin.ts
Removed optimizeDeps.exclude property for client environment, allowing all dependencies to proceed through standard dependency optimization crawling instead of being excluded

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

package: start-plugin-core

Suggested reviewers

  • lachlancollins

Poem

🐰 No more excluding, let them roam free,
Dependencies bundle where they should be,
Server stays server, client stays clean,
The finest bundling you've ever seen! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: removing crawlFrameworkPkgs from optimizeDeps.exclude in the start-plugin-core package, which is exactly what the code change implements.
Linked Issues check ✅ Passed The PR directly addresses issue #5738 by removing the optimizeDeps.exclude configuration that was preventing Vite from pre-bundling third-party packages, allowing server-side dependencies to leak into client bundles. The change aligns with the expected behavior of properly externalizing server-side modules.
Out of Scope Changes check ✅ Passed The change is narrowly scoped to removing one line from the optimizeDeps.exclude property in the client environment configuration. This directly addresses the root cause identified in issue #5738 with no extraneous modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d87a631 and c72ac65.

📒 Files selected for processing (1)
  • packages/start-plugin-core/src/plugin.ts
💤 Files with no reviewable changes (1)
  • packages/start-plugin-core/src/plugin.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Preview
  • GitHub Check: Test

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

@nx-cloud
Copy link

nx-cloud bot commented Jan 11, 2026

View your CI Pipeline Execution ↗ for commit c72ac65

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

☁️ Nx Cloud last updated this comment at 2026-01-11 15:12:55 UTC

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 11, 2026

More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/arktype-adapter@6361

@tanstack/eslint-plugin-router

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

@tanstack/history

npm i https://pkg.pr.new/TanStack/router/@tanstack/history@6361

@tanstack/nitro-v2-vite-plugin

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

@tanstack/react-router

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

@tanstack/react-router-devtools

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

@tanstack/react-router-ssr-query

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

@tanstack/react-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start@6361

@tanstack/react-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-client@6361

@tanstack/react-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-server@6361

@tanstack/router-cli

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

@tanstack/router-core

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

@tanstack/router-devtools

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

@tanstack/router-devtools-core

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

@tanstack/router-generator

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

@tanstack/router-plugin

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

@tanstack/router-ssr-query-core

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

@tanstack/router-utils

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

@tanstack/router-vite-plugin

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

@tanstack/solid-router

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

@tanstack/solid-router-devtools

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

@tanstack/solid-router-ssr-query

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

@tanstack/solid-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start@6361

@tanstack/solid-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-client@6361

@tanstack/solid-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-server@6361

@tanstack/start-client-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-client-core@6361

@tanstack/start-fn-stubs

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-fn-stubs@6361

@tanstack/start-plugin-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-plugin-core@6361

@tanstack/start-server-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-core@6361

@tanstack/start-static-server-functions

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

@tanstack/start-storage-context

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-storage-context@6361

@tanstack/valibot-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/valibot-adapter@6361

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/TanStack/router/@tanstack/virtual-file-routes@6361

@tanstack/vue-router

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

@tanstack/vue-router-devtools

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

@tanstack/vue-router-ssr-query

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

@tanstack/vue-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-start@6361

@tanstack/vue-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-start-client@6361

@tanstack/vue-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-start-server@6361

@tanstack/zod-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/zod-adapter@6361

commit: c72ac65

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.

Some server-side modules incorrectly bundled into the client?

2 participants