mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[GH-ISSUE #1] Virtual module imports break esbuild dependency optimization when vinext is installed from npm #3
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#3
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 @threepointone on GitHub (Feb 24, 2026).
Original GitHub issue: https://github.com/cloudflare/vinext/issues/1
Description
When vinext is installed as an npm package (rather than a symlinked local dependency),
vite devfails with:This happens during esbuild's dependency optimization pass. The optimizer scans
vinext/dist/server/app-router-entry.js, encounters thevirtual:vinext-rsc-entryimport, and fails because virtual modules only exist at Vite plugin resolution time — not during esbuild's pre-bundling scan.Why this wasn't an issue before
When vinext is a symlinked package (
"vinext": "link:../vinext/packages/vinext"), Vite automatically excludes linked packages from dependency optimization. Once installed from npm ("vinext": "^0.0.1"), esbuild starts scanning it and hits the unresolvable virtual imports.The error occurs in multiple Vite environments (client, rsc, ssr) since
app-router-entry.jscan be pulled into the dep optimization graph from any of them.Proposed fix
The vinext plugin should add an esbuild plugin in its
config()hook to externalize its own virtual modules during dependency optimization:This is targeted — it only externalizes vinext's own
virtual:vinext-*modules during the esbuild scan, without affecting pre-bundling of anything else.An alternative (less targeted) approach would be to add
"vinext"tooptimizeDeps.excludefor all environments, but this prevents pre-bundling of all vinext exports even when unnecessary.Current workaround
Users can add this to their
vite.config.ts:This needs to cover all three environments (client via top-level, rsc, ssr) to prevent the error in each.