-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix(start-plugin-core): remove crawlFrameworkPkgs from optimizeDeps.exclude #6361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…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
📝 WalkthroughWalkthroughRemoved the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
📜 Recent review detailsConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
⏰ 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)
Comment |
|
View your CI Pipeline Execution ↗ for commit c72ac65
☁️ Nx Cloud last updated this comment at |
Summary
Fixes #5738 - Server-side modules incorrectly bundled into the client
Starting with
@tanstack/[email protected], server-side modules (like thecookiemodule from Clerk SDK) were incorrectly being bundled into the client bundle, causing runtime errors like:Root Cause
The
crawlFrameworkPkgsfunction finds packages that have@tanstack/react-startor@tanstack/start-client-coreaspeerDependenciesand was adding them tooptimizeDeps.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.excludefrom the client environment'soptimizeDepsconfiguration. This allows Vite to properly pre-bundle third-party packages and their dependencies.Testing
Verified the fix works with:
@clerk/tanstack-react-start) - No morecookiemodule errors@tanstack-themes/react) - Works correctly@tanstack/react-form) - No moreuse-sync-external-storeerrorsAll unit and type tests pass.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.