Skip to content

fix(tanstack-start): keep database adapters out of the client dep optimizer - #18313

Merged
r1tsuu merged 1 commit into
mainfrom
fix/tanstack-exclude-db-adapters-from-client-optimizer
Sep 25, 2026
Merged

r1tsuu merged 1 commit into
mainfrom
fix/tanstack-exclude-db-adapters-from-client-optimizer

Conversation

@r1tsuu

@r1tsuu r1tsuu commented Sep 25, 2026

Copy link
Copy Markdown
Member

pnpm dev:tanstack in the monorepo crashes on boot with [MISSING_EXPORT] "fromTokenFile" is not exported by ".../@aws-sdk/credential-provider-web-identity/dist-es/index.js".

Vite's client dep scan follows import('@payload-config') in server functions, reaches the database adapter, and pre-bundles the driver for the browser. Mongoose 9 (#17747) has no browser build, so this now pulls in mongodb and its optional @aws-sdk/credential-providers peer, whose browser build doesn't export fromTokenFile. Published installs don't crash, but they still bundle @payloadcms/db-mongodb into a browser chunk nothing loads.

This excludes the @payloadcms/db-* adapters, @payloadcms/drizzle, mongoose and mongodb from the client optimizer, like the existing @azure/storage-blob exclusion.

…imizer

The client dep scan follows server functions' `import('@payload-config')`
without TanStack's server-fn stripping, so it reaches the database adapter
and pre-bundles the whole driver for the browser. Mongoose 9 has no browser
build, so that bundles `mongodb`; when its optional
`@aws-sdk/credential-providers` peer is linked (as in the monorepo, via
`@payloadcms/payload-cloud`), the browser build of
`credential-provider-web-identity` drops `fromTokenFile` and the dev server
crashes with a `MISSING_EXPORT` error before serving anything.

Exclude the adapter packages (reached by published installs) and the
`mongoose`/`mongodb` drivers (reached by the monorepo, which resolves the
adapters to source) from `optimizeDeps`.
@github-actions

Copy link
Copy Markdown
Contributor

📦 esbuild Bundle Analysis for payload

This analysis was generated by esbuild-bundle-analyzer. 🤖
This PR introduced no changes to the esbuild bundle! 🙌

@r1tsuu
r1tsuu requested a review from jacobsfletch September 25, 2026 12:02
@r1tsuu
r1tsuu merged commit d1a2aab into main Sep 25, 2026
288 checks passed
@r1tsuu
r1tsuu deleted the fix/tanstack-exclude-db-adapters-from-client-optimizer branch September 25, 2026 13:20
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

🚀 This is included in version v4.0.0-canary.38

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.

2 participants