Skip to content

fix: exclude vinext from optimizeDeps to prevent virtual module resolution errors#3

Merged
southpolesteve merged 2 commits intomainfrom
fix/exclude-vinext-from-optimizedeps
Feb 24, 2026
Merged

fix: exclude vinext from optimizeDeps to prevent virtual module resolution errors#3
southpolesteve merged 2 commits intomainfrom
fix/exclude-vinext-from-optimizedeps

Conversation

@threepointone
Copy link
Collaborator

Problem

When vinext is installed from npm (not symlinked), vite dev fails with:

✘ [ERROR] Could not resolve "virtual:vinext-rsc-entry"

esbuild's dependency optimization scans vinext/dist/ and hits virtual:vinext-* imports that only exist at Vite plugin resolution time. This occurs in all three environments (client, rsc, ssr).

Fix

Adds optimizeDeps.exclude: ["vinext"] at the top level and in each environment config (rsc, ssr, client). This prevents esbuild from scanning vinext's dist files during pre-bundling.

Uses the stable optimizeDeps.exclude API rather than an esbuild plugin, so it won't break in future Vite majors.

Fixes #1

…ution errors

When vinext is installed from npm (not symlinked), esbuild's dependency
optimization scans vinext/dist/ and hits virtual:vinext-* imports that
only exist at Vite plugin resolution time. This causes build failures
in all three environments (client, rsc, ssr).

Adding optimizeDeps.exclude: ['vinext'] at the top level and in each
environment prevents esbuild from scanning vinext's dist files entirely.

Fixes #1
@github-actions
Copy link

Example Preview Production Original
app-router-cloudflare preview production
pages-router-cloudflare preview production
app-router-playground preview production original
realworld-api-rest preview production
nextra-docs-template preview production
benchmarks preview production
hackernews preview production original

@southpolesteve
Copy link
Collaborator

/bigbonk give this a review

@southpolesteve southpolesteve merged commit 3ed38d1 into main Feb 24, 2026
17 checks passed
@southpolesteve southpolesteve deleted the fix/exclude-vinext-from-optimizedeps branch February 24, 2026 17:13
southpolesteve added a commit that referenced this pull request Feb 27, 2026
…mmands, COST.md

- Benchmarks: Rollup 2.4x faster, Rolldown 6.2x faster, 55-56% smaller bundles
- "use cache" now marked Full (was "Not yet") — directive, cacheLife, cacheTag all work
- Added vinext deploy and vinext check to CLI reference
- Updated vinext deploy section from "coming soon" to actual capabilities
- Added connection() and static export as Full features
- Test counts: 844 vitest + 278 Playwright E2E
- COST.md: 207 commits, ~45K source lines, ~25K test lines
- Downgraded PPR (#3) from P1 to P2 (still experimental in Next.js)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Virtual module imports break esbuild dependency optimization when vinext is installed from npm

2 participants