mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[GH-ISSUE #710] Pages Router deploy broken from v0.0.26+: wrangler cannot resolve virtual:vinext-server-entry #153
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#153
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @aashishvanand on GitHub (Mar 29, 2026).
Original GitHub issue: https://github.com/cloudflare/vinext/issues/710
Description
Starting from vinext v0.0.26, Pages Router projects with custom
worker/index.tsentries fail to deploy to Cloudflare Workers. Thevinext deploycommand (andvinext build && vinext deploy --skip-build) fails because wrangler's esbuild bundler cannot resolve thevirtual:vinext-server-entryvirtual module that vinext now generates inworker/index.ts.Environment
Steps to Reproduce
worker/index.ts(auto-generated byvinext deploy --dry-run)vinext build && vinext deploy --skip-buildError 1: Virtual module not resolved
When using
vinext build && vinext deploy --skip-build, wrangler's esbuild bundler cannot resolve the virtual module:Error 2: Adding wrangler alias — file not found
Adding
"alias": { "virtual:vinext-server-entry": "./dist/server/entry.js" }towrangler.jsoncresolves the virtual module, but when usingvinext deploy(without--skip-build),dist/server/entry.jsdoesn't exist because the server build is skipped entirely — only the client is built:Error 3: Missing client entry globals (UI stuck on loading)
Even when deploy succeeds (using the alias +
vinext build && vinext deploy --skip-build), the UI is stuck on "Loading API Documentation..." because vinext's post-build hook doesn't inject__VINEXT_CLIENT_ENTRY__/__VINEXT_SSR_MANIFEST__globals for Pages Router. The hook looks for awrangler.jsonfile in a dist subdirectory (line ~2274 ofdist/index.js) which doesn't exist, so it returns early without injecting the client entry script tag into the HTML.Root Cause
Four issues combine:
@cloudflare/vite-plugininvite.config.ts— builds fail without it (Error: [vinext] Missing @cloudflare/vite-plugin)worker/index.tsusesvirtual:vinext-server-entry— this is a Vite virtual module that wrangler's esbuild bundler cannot resolvevinext deploycallswrangler deploydirectly (viaexecFileSyncatdeploy.js:914) which re-bundles the worker with esbuild, bypassing Vite's plugin pipeline where virtual modules are resolved__VINEXT_CLIENT_ENTRY__/__VINEXT_SSR_MANIFEST__globals — it looks for a directory withwrangler.jsonin dist (index.js:2274) which doesn't exist with the cloudflare() plugin, causing the client entry script to never be injected into the HTMLWorkaround
Pin vinext to v0.0.25 and use the old worker pattern with direct imports:
With
vite.config.ts(no cloudflare plugin needed on v0.0.25):Deploy script:
vinext build && vinext deploy --skip-buildExpected Behavior
vinext deployshould work for Pages Router projects with custom worker entries, either by:virtual:vinext-server-entry__VINEXT_CLIENT_ENTRY__and__VINEXT_SSR_MANIFEST__globals in the post-build step for Pages Router@james-elicx commented on GitHub (Mar 29, 2026):
Are you able to share a minimal reproduction repository?
@aashishvanand commented on GitHub (Mar 29, 2026):
Here's a minimal reproduction repository:
https://github.com/aashishvanand/vinext-pages-router-repro
To reproduce
✅ Works on v0.0.25 (current pinned version)
❌ Breaks on v0.0.26+
Fails immediately:
After adding
cloudflare()to vite.config.ts and runningvinext deploy --dry-run, the worker gets regenerated withvirtual:vinext-server-entry, andwrangler deployfails:What the repro shows
src/pages/index.tsxwith a dynamic import)worker/index.tsusing direct imports (the workaround that works on v0.0.25)wrangler.jsoncwith Workers deployment configworker/index.tsmanually sets__VINEXT_SSR_MANIFEST__and__VINEXT_CLIENT_ENTRY__globals which vinext's post-build hook fails to inject for Pages Router from v0.0.26+@james-elicx commented on GitHub (Mar 29, 2026):
Looks like we weren't building with the Vite config properly if you ran
vinext buildin a pager router-only project. Should be fixed in the next release.