router: [start/devinxi] any cloudflare target: Cannot resolve "tanstack-start-server-fn-manifest:v"
Which project does this relate to?
Start
Describe the bug
gh clone Balastrong/confhub
cd confhub
install nodejs/pnpm
pnpm i
pnpm build
It works with tanstackStart({ target: "netlify" })
Change to tanstackStart({ target: "cloudflare-module" }) (or any other variation of cloudflare*
pnpm i
pnpm build
results in some variation of
confhub on git main [!?] is pkg v1.0.0 via nodejs v24.1.0 took 12s
> pnpm build
> confhub@1.0.0 build /mnt/Store/Projects/Others/confhub
> vite build
vite v6.3.5 building for production...
♻️ Generating routes...
✅ Processed routes in 95ms
✓ 2742 modules transformed.
.tanstack-start/build/client-dist/.vite/manifest.json 8.13 kB │ gzip: 1.07 kB
.tanstack-start/build/client-dist/assets/globals-qFwBf5NC.css 37.68 kB │ gzip: 7.15 kB
.tanstack-start/build/client-dist/assets/useSuspenseQuery-Bay2iilc.js 0.17 kB │ gzip: 0.16 kB
.tanstack-start/build/client-dist/assets/layout-DSgTZFmb.js 0.17 kB │ gzip: 0.16 kB
.tanstack-start/build/client-dist/assets/chevron-left-DhgusbFB.js 0.30 kB │ gzip: 0.25 kB
.tanstack-start/build/client-dist/assets/loader-circle-CzoE4StM.js 0.31 kB │ gzip: 0.26 kB
.tanstack-start/build/client-dist/assets/map-pin-vX-d9_wT.js 0.43 kB │ gzip: 0.33 kB
.tanstack-start/build/client-dist/assets/skeleton-BsDkB0Uj.js 0.45 kB │ gzip: 0.33 kB
.tanstack-start/build/client-dist/assets/separator-BmTNHxxu.js 0.67 kB │ gzip: 0.40 kB
.tanstack-start/build/client-dist/assets/submit-1_K2QWHb.js 0.81 kB │ gzip: 0.48 kB
.tanstack-start/build/client-dist/assets/_eventId-DyGQjDcI.js 0.92 kB │ gzip: 0.54 kB
.tanstack-start/build/client-dist/assets/card-D8AoOOLS.js 1.00 kB │ gzip: 0.38 kB
.tanstack-start/build/client-dist/assets/input-j54pwyDy.js 1.05 kB │ gzip: 0.56 kB
.tanstack-start/build/client-dist/assets/badge-EvTVK2Ap.js 1.09 kB │ gzip: 0.59 kB
.tanstack-start/build/client-dist/assets/sign-in-CHBR8MUy.js 1.34 kB │ gzip: 0.72 kB
.tanstack-start/build/client-dist/assets/create-CAL4GaNn.js 1.35 kB │ gzip: 0.70 kB
.tanstack-start/build/client-dist/assets/profile-DVYArpiR.js 1.51 kB │ gzip: 0.76 kB
.tanstack-start/build/client-dist/assets/sign-up-CsAoGysN.js 1.60 kB │ gzip: 0.75 kB
.tanstack-start/build/client-dist/assets/_communityId-BFwLYQ1c.js 4.40 kB │ gzip: 1.75 kB
.tanstack-start/build/client-dist/assets/index-bGp0UP6z.js 10.47 kB │ gzip: 3.77 kB
.tanstack-start/build/client-dist/assets/calendar-DaaX_z_T.js 10.90 kB │ gzip: 4.19 kB
.tanstack-start/build/client-dist/assets/submit-form-CxOwr6Zl.js 13.68 kB │ gzip: 4.41 kB
.tanstack-start/build/client-dist/assets/form-DlcZF9rG.js 52.09 kB │ gzip: 16.03 kB
.tanstack-start/build/client-dist/assets/index-Brc9JZzw.js 57.22 kB │ gzip: 18.02 kB
.tanstack-start/build/client-dist/assets/main-CO4q6_5Z.js 593.82 kB │ gzip: 183.95 kB
(!) Some chunks are larger than 500 kB after minification. Consider:
- Using dynamic import() to code-split the application
- Use build.rollupOptions.output.manualChunks to improve chunking: https://rollupjs.org/configuration-options/#output-manualchunks
- Adjust chunk size limit for this warning via build.chunkSizeWarningLimit.
✓ built in 3.44s
vite v6.3.5 building SSR bundle for production...
✓ 316 modules transformed.
[plugin vite:css-post] Sourcemap is likely to be incorrect: a plugin (vite:css-post) was used to transform files, but didn't generate a sourcemap for the transformation. Consult the plugin documentation for help
✓ built in 953ms
✔ Generated public .output/public nitro 9:22:35 am
WARN [cloudflare] Node.js compatibility is not enabled. nitro 9:22:35 am
ℹ Building Nitro Server (preset: cloudflare-module, compatibility date: 2024-11-19) nitro 9:22:35 am
node_modules/.pnpm/react-error-boundary@5.0.0_react@19.1.0/node_modules/react-error-boundary/dist/react-error-boundary.esm.js (1:0): Module level directives cause errors when bundled, "use client" in "node_modules/.pnpm/react-error-boundary@5.0.0_react@19.1.0/node_modules/react-error-boundary/dist/react-error-boundary.esm.js" was ignored.
node_modules/.pnpm/sonner@1.7.4_react-dom@19.1.0_react@19.1.0/node_modules/sonner/dist/index.mjs (1:0): Module level directives cause errors when bundled, "use client" in "node_modules/.pnpm/sonner@1.7.4_react-dom@19.1.0_react@19.1.0/node_modules/sonner/dist/index.mjs" was ignored.
node_modules/.pnpm/@radix-ui+react-navigation-menu@1.2.13_@types+react-dom@18.3.7_@types+react@18.3.23_react-dom@19.1.0_react@19.1.0/node_modules/@radix-ui/react-navigation-menu/dist/index.mjs (1:0): Module level directives cause errors when bundled, "use client" in "node_modules/.pnpm/@radix-ui+react-navigation-menu@1.2.13_@types+react-dom@18.3.7_@types+react@18.3.23_react-dom@19.1.0_react@19.1.0/node_modules/@radix-ui/react-navigation-menu/dist/index.mjs" was ignored.
node_modules/.pnpm/@radix-ui+react-dropdown-menu@2.1.15_@types+react-dom@18.3.7_@types+react@18.3.23_react-dom@19.1.0_react@19.1.0/node_modules/@radix-ui/react-dropdown-menu/dist/index.mjs (1:0): Module level directives cause errors when bundled, "use client" in "node_modules/.pnpm/@radix-ui+react-dropdown-menu@2.1.15_@types+react-dom@18.3.7_@types+react@18.3.23_react-dom@19.1.0_react@19.1.0/node_modules/@radix-ui/react-dropdown-menu/dist/index.mjs" was ignored.
node_modules/.pnpm/@radix-ui+react-avatar@1.1.10_@types+react-dom@18.3.7_@types+react@18.3.23_react-dom@19.1.0_react@19.1.0/node_modules/@radix-ui/react-avatar/dist/index.mjs (1:0): Module level directives cause errors when bundled, "use client" in "node_modules/.pnpm/@radix-ui+react-avatar@1.1.10_@types+react-dom@18.3.7_@types+react@18.3.23_react-dom@19.1.0_react@19.1.0/node_modules/@radix-ui/react-avatar/dist/index.mjs" was ignored.
node_modules/.pnpm/@radix-ui+react-switch@1.2.5_@types+react-dom@18.3.7_@types+react@18.3.23_react-dom@19.1.0_react@19.1.0/node_modules/@radix-ui/react-switch/dist/index.mjs (1:0): Module level directives cause errors when bundled, "use client" in "node_modules/.pnpm/@radix-ui+react-switch@1.2.5_@types+react-dom@18.3.7_@types+react@18.3.23_react-dom@19.1.0_react@19.1.0/node_modules/@radix-ui/react-switch/dist/index.mjs" was ignored.
node_modules/.pnpm/@radix-ui+react-label@2.1.7_@types+react-dom@18.3.7_@types+react@18.3.23_react-dom@19.1.0_react@19.1.0/node_modules/@radix-ui/react-label/dist/index.mjs (1:0): Module level directives cause errors when bundled, "use client" in "node_modules/.pnpm/@radix-ui+react-label@2.1.7_@types+react-dom@18.3.7_@types+react@18.3.23_react-dom@19.1.0_react@19.1.0/node_modules/@radix-ui/react-label/dist/index.mjs" was ignored.
node_modules/.pnpm/@radix-ui+react-checkbox@1.3.2_@types+react-dom@18.3.7_@types+react@18.3.23_react-dom@19.1.0_react@19.1.0/node_modules/@radix-ui/react-checkbox/dist/index.mjs (1:0): Module level directives cause errors when bundled, "use client" in "node_modules/.pnpm/@radix-ui+react-checkbox@1.3.2_@types+react-dom@18.3.7_@types+react@18.3.23_react-dom@19.1.0_react@19.1.0/node_modules/@radix-ui/react-checkbox/dist/index.mjs" was ignored.
node_modules/.pnpm/@radix-ui+react-dialog@1.1.14_@types+react-dom@18.3.7_@types+react@18.3.23_react-dom@19.1.0_react@19.1.0/node_modules/@radix-ui/react-dialog/dist/index.mjs (1:0): Module level directives cause errors when bundled, "use client" in "node_modules/.pnpm/@radix-ui+react-dialog@1.1.14_@types+react-dom@18.3.7_@types+react@18.3.23_react-dom@19.1.0_react@19.1.0/node_modules/@radix-ui/react-dialog/dist/index.mjs" was ignored.
node_modules/.pnpm/@radix-ui+react-select@2.2.5_@types+react-dom@18.3.7_@types+react@18.3.23_react-dom@19.1.0_react@19.1.0/node_modules/@radix-ui/react-select/dist/index.mjs (1:0): Module level directives cause errors when bundled, "use client" in "node_modules/.pnpm/@radix-ui+react-select@2.2.5_@types+react-dom@18.3.7_@types+react@18.3.23_react-dom@19.1.0_react@19.1.0/node_modules/@radix-ui/react-select/dist/index.mjs" was ignored.
node_modules/.pnpm/@radix-ui+react-hover-card@1.1.14_@types+react-dom@18.3.7_@types+react@18.3.23_react-dom@19.1.0_react@19.1.0/node_modules/@radix-ui/react-hover-card/dist/index.mjs (1:0): Module level directives cause errors when bundled, "use client" in "node_modules/.pnpm/@radix-ui+react-hover-card@1.1.14_@types+react-dom@18.3.7_@types+react@18.3.23_react-dom@19.1.0_react@19.1.0/node_modules/@radix-ui/react-hover-card/dist/index.mjs" was ignored.
node_modules/.pnpm/@radix-ui+react-accordion@1.2.11_@types+react-dom@18.3.7_@types+react@18.3.23_react-dom@19.1.0_react@19.1.0/node_modules/@radix-ui/react-accordion/dist/index.mjs (1:0): Module level directives cause errors when bundled, "use client" in "node_modules/.pnpm/@radix-ui+react-accordion@1.2.11_@types+react-dom@18.3.7_@types+react@18.3.23_react-dom@19.1.0_react@19.1.0/node_modules/@radix-ui/react-accordion/dist/index.mjs" was ignored.
node_modules/.pnpm/@radix-ui+react-popover@1.1.14_@types+react-dom@18.3.7_@types+react@18.3.23_react-dom@19.1.0_react@19.1.0/node_modules/@radix-ui/react-popover/dist/index.mjs (1:0): Module level directives cause errors when bundled, "use client" in "node_modules/.pnpm/@radix-ui+react-popover@1.1.14_@types+react-dom@18.3.7_@types+react@18.3.23_react-dom@19.1.0_react@19.1.0/node_modules/@radix-ui/react-popover/dist/index.mjs" was ignored.
node_modules/.pnpm/@radix-ui+react-presence@1.1.4_@types+react-dom@18.3.7_@types+react@18.3.23_react-dom@19.1.0_react@19.1.0/node_modules/@radix-ui/react-presence/dist/index.mjs (1:0): Module level directives cause errors when bundled, "use client" in "node_modules/.pnpm/@radix-ui+react-presence@1.1.4_@types+react-dom@18.3.7_@types+react@18.3.23_react-dom@19.1.0_react@19.1.0/node_modules/@radix-ui/react-presence/dist/index.mjs" was ignored.
node_modules/.pnpm/@radix-ui+react-dismissable-layer@1.1.10_@types+react-dom@18.3.7_@types+react@18.3.23_react-dom@19.1.0_react@19.1.0/node_modules/@radix-ui/react-dismissable-layer/dist/index.mjs (1:0): Module level directives cause errors when bundled, "use client" in "node_modules/.pnpm/@radix-ui+react-dismissable-layer@1.1.10_@types+react-dom@18.3.7_@types+react@18.3.23_react-dom@19.1.0_react@19.1.0/node_modules/@radix-ui/react-dismissable-layer/dist/index.mjs" was ignored.
node_modules/.pnpm/@radix-ui+react-collection@1.1.7_@types+react-dom@18.3.7_@types+react@18.3.23_react-dom@19.1.0_react@19.1.0/node_modules/@radix-ui/react-collection/dist/index.mjs (1:0): Module level directives cause errors when bundled, "use client" in "node_modules/.pnpm/@radix-ui+react-collection@1.1.7_@types+react-dom@18.3.7_@types+react@18.3.23_react-dom@19.1.0_react@19.1.0/node_modules/@radix-ui/react-collection/dist/index.mjs" was ignored.
node_modules/.pnpm/@radix-ui+react-menu@2.1.15_@types+react-dom@18.3.7_@types+react@18.3.23_react-dom@19.1.0_react@19.1.0/node_modules/@radix-ui/react-menu/dist/index.mjs (1:0): Module level directives cause errors when bundled, "use client" in "node_modules/.pnpm/@radix-ui+react-menu@2.1.15_@types+react-dom@18.3.7_@types+react@18.3.23_react-dom@19.1.0_react@19.1.0/node_modules/@radix-ui/react-menu/dist/index.mjs" was ignored.
node_modules/.pnpm/@radix-ui+react-portal@1.1.9_@types+react-dom@18.3.7_@types+react@18.3.23_react-dom@19.1.0_react@19.1.0/node_modules/@radix-ui/react-portal/dist/index.mjs (1:0): Module level directives cause errors when bundled, "use client" in "node_modules/.pnpm/@radix-ui+react-portal@1.1.9_@types+react-dom@18.3.7_@types+react@18.3.23_react-dom@19.1.0_react@19.1.0/node_modules/@radix-ui/react-portal/dist/index.mjs" was ignored.
node_modules/.pnpm/@radix-ui+react-focus-guards@1.1.2_@types+react@18.3.23_react@19.1.0/node_modules/@radix-ui/react-focus-guards/dist/index.mjs (1:0): Module level directives cause errors when bundled, "use client" in "node_modules/.pnpm/@radix-ui+react-focus-guards@1.1.2_@types+react@18.3.23_react@19.1.0/node_modules/@radix-ui/react-focus-guards/dist/index.mjs" was ignored.
node_modules/.pnpm/@radix-ui+react-focus-scope@1.1.7_@types+react-dom@18.3.7_@types+react@18.3.23_react-dom@19.1.0_react@19.1.0/node_modules/@radix-ui/react-focus-scope/dist/index.mjs (1:0): Module level directives cause errors when bundled, "use client" in "node_modules/.pnpm/@radix-ui+react-focus-scope@1.1.7_@types+react-dom@18.3.7_@types+react@18.3.23_react-dom@19.1.0_react@19.1.0/node_modules/@radix-ui/react-focus-scope/dist/index.mjs" was ignored.
node_modules/.pnpm/@radix-ui+react-popper@1.2.7_@types+react-dom@18.3.7_@types+react@18.3.23_react-dom@19.1.0_react@19.1.0/node_modules/@radix-ui/react-popper/dist/index.mjs (1:0): Module level directives cause errors when bundled, "use client" in "node_modules/.pnpm/@radix-ui+react-popper@1.2.7_@types+react-dom@18.3.7_@types+react@18.3.23_react-dom@19.1.0_react@19.1.0/node_modules/@radix-ui/react-popper/dist/index.mjs" was ignored.
node_modules/.pnpm/@radix-ui+react-collapsible@1.1.11_@types+react-dom@18.3.7_@types+react@18.3.23_react-dom@19.1.0_react@19.1.0/node_modules/@radix-ui/react-collapsible/dist/index.mjs (1:0): Module level directives cause errors when bundled, "use client" in "node_modules/.pnpm/@radix-ui+react-collapsible@1.1.11_@types+react-dom@18.3.7_@types+react@18.3.23_react-dom@19.1.0_react@19.1.0/node_modules/@radix-ui/react-collapsible/dist/index.mjs" was ignored.
node_modules/.pnpm/@radix-ui+react-roving-focus@1.1.10_@types+react-dom@18.3.7_@types+react@18.3.23_react-dom@19.1.0_react@19.1.0/node_modules/@radix-ui/react-roving-focus/dist/index.mjs (1:0): Module level directives cause errors when bundled, "use client" in "node_modules/.pnpm/@radix-ui+react-roving-focus@1.1.10_@types+react-dom@18.3.7_@types+react@18.3.23_react-dom@19.1.0_react@19.1.0/node_modules/@radix-ui/react-roving-focus/dist/index.mjs" was ignored.
[nitro 9:22:46 am] ERROR Error: Cannot resolve "tanstack-start-server-fn-manifest:v" from "/mnt/Store/Projects/Others/confhub/node_modules/.pnpm/@tanstack+start-server-core@1.121.0-alpha.17/node_modules/@tanstack/start-server-core/dist/esm/server-functions-handler.js" and externals are not allowed!
undefined
error during build:
Error: Cannot resolve "tanstack-start-server-fn-manifest:v" from "/mnt/Store/Projects/Others/confhub/node_modules/.pnpm/@tanstack+start-server-core@1.121.0-alpha.17/node_modules/@tanstack/start-server-core/dist/esm/server-functions-handler.js" and externals are not allowed!
at Object.resolveId (file:///mnt/Store/Projects/Others/confhub/node_modules/.pnpm/nitropack@2.11.12_drizzle-orm@0.43.1/node_modules/nitropack/dist/rollup/index.mjs:2013:17)
at async PluginDriver.hookFirstAndGetPlugin (file:///mnt/Store/Projects/Others/confhub/node_modules/.pnpm/rollup@4.41.1/node_modules/rollup/dist/es/shared/node-entry.js:22131:28)
at async resolveId (file:///mnt/Store/Projects/Others/confhub/node_modules/.pnpm/rollup@4.41.1/node_modules/rollup/dist/es/shared/node-entry.js:20613:26)
at async ModuleLoader.resolveId (file:///mnt/Store/Projects/Others/confhub/node_modules/.pnpm/rollup@4.41.1/node_modules/rollup/dist/es/shared/node-entry.js:21049:15)
at async Object.resolveId (file:///mnt/Store/Projects/Others/confhub/node_modules/.pnpm/@rollup+plugin-commonjs@28.0.3_rollup@4.41.1/node_modules/@rollup/plugin-commonjs/dist/es/index.js:600:10)
at async PluginDriver.hookFirstAndGetPlugin (file:///mnt/Store/Projects/Others/confhub/node_modules/.pnpm/rollup@4.41.1/node_modules/rollup/dist/es/shared/node-entry.js:22131:28)
at async resolveId (file:///mnt/Store/Projects/Others/confhub/node_modules/.pnpm/rollup@4.41.1/node_modules/rollup/dist/es/shared/node-entry.js:20613:26)
at async ModuleLoader.resolveId (file:///mnt/Store/Projects/Others/confhub/node_modules/.pnpm/rollup@4.41.1/node_modules/rollup/dist/es/shared/node-entry.js:21049:15)
at async ModuleLoader.resolveDynamicImport (file:///mnt/Store/Projects/Others/confhub/node_modules/.pnpm/rollup@4.41.1/node_modules/rollup/dist/es/shared/node-entry.js:21449:82)
at async file:///mnt/Store/Projects/Others/confhub/node_modules/.pnpm/rollup@4.41.1/node_modules/rollup/dist/es/shared/node-entry.js:21337:32
ELIFECYCLE Command failed with exit code 1.
Your Example Website or App
https://stackblitz.com/~/github.com/airtonix/confhub?file=vite.config.ts
Steps to Reproduce the Bug or Issue
pnpm i
pnpm build
Expected behavior
Build should succeed and wrangler --cwd .output/ dev should work
Screenshots or Videos
No response
Platform
- Browser: Firefox 138.0.4 (64-bit)
"@tanstack/react-router": "^1.121.0-alpha.14",
"@tanstack/react-router-with-query": "^1.121.0-alpha.14",
"@tanstack/react-start": "^1.121.0-alpha.17",
"@tanstack/router-core": "^1.121.0-alpha.14",
x inxi -S
System:
Host: brass Kernel: 6.14.4-100.fc40.x86_64 arch: x86_64 bits: 64
Desktop: GNOME v: 48.1 Distro: Fedora Linux 42 (Workstation Edition)
Additional context
I just forked someone elses repo https://github.com/Balastrong/confhub/ to demonstrate
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 2
- Comments: 18 (1 by maintainers)
Commits related to this issue
- fix: exclude virtual modules from optimizeDeps fixes #4285 fixes #4195 fixes #4182 — committed to TanStack/router by schiller-manuel a year ago
- fix: exclude virtual modules from optimizeDeps (#4295) Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> fixes #4285 fixes #4195 fixes #4182 — committed to TanStack/router by schiller-manuel a year ago
- document workaround for nitro server build virtual modules issue as reported here https://github.com/cloudflare/workers-sdk/issues/9622 and https://github.com/TanStack/router/issues/4285#issuecomm... — committed to capaj/router-1 by capaj a year ago
@schiller-manuel the error is gone if a Nitro config is provided. Just vibe fixed it 😂
nitro.config.ts
Used O3 to fix this. Details
Why the build failed before
reactStartCookies()imports@tanstack/react-start/server→ that traverses into@tanstack/start-server-core.Inside start-server-core the helper
loadVirtualModule()does dynamic imports of three virtual module IDs:•
tanstack-start-route-tree:v•
tanstack-start-manifest:v•
tanstack-start-server-fn-manifest:vDuring a normal Vite build these IDs are supplied by the TanStack-Start Vite plugin and everything is fine.
After Vite finishes, TanStack-Start hands the SSR bundle to Nitro, which runs its own Rollup build.
That second build does not carry over the Vite plugin that declares those virtual modules, so Rollup can’t resolve the IDs and throws the error you saw.
What the patch does
Nitro’s config lets us inject extra Rollup plugins.
The custom plugin we added:
• watches for those three exact IDs in
resolveId()and returns the ID itself so Rollup treats it as resolved;• returns a tiny stub (
export default {}) inload()so the module actually exists.Because Rollup now finds code for every import statement, it no longer aborts, and the rest of the build (and Nitro packaging) proceeds normally.
Why a stub is enough
reactStartCookies()only neededsetCookiefrom@tanstack/react-start/server(which is present); nothing in your runtime path ever reaches into the route-tree or manifest modules, so empty stubs satisfy the linker without impacting runtime behaviour.In short, we gave Nitro a local map for those virtual files, eliminating the unresolved-module error, and that’s why the build now succeeds with
reactStartCookies()enabled.Thanks nogo.
@schiller-manuel found the problem.
The issue was with the
reactStartCookies()frombetter-authIf I comment, the
reactStartCookies()the build works great.Also, I am targeting
cloudflare-moduleI am not sure if this is a better auth problem or not but this is part of the documentation https://www.better-auth.com/docs/integrations/tanstack
start-basic.zip
I had this issue when I was trying to use the
getCookiemethod on the client side. Removed that and it successfully built.Difficult to say but I had removed src/api.ts, src/client.tsx and src/global-middleware.ts as well as some packages like @vitejs/plugin-react.
cc @Balastrong 👆🏻
Thank you @schiller-manuel
I initialized everything with a new project and copied piece by piece. It look like I had some leftovers from the old vinxi project.