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
Copy Markdown
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
Copy Markdown

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
Copy Markdown
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)
james-elicx added a commit to NathanDrake2406/vinext that referenced this pull request Mar 12, 2026
- Bug cloudflare#2: hybrid build skipped Pages Router pre-rendering when App Router entry
  also present — fix: only bail out on pure App Router builds (no pages entry)
- Bug #1: getOutputPath traversal guard bypassed on Windows by backslash urlPath
  — fix: reject urlPath containing backslashes before posix normalize
- Bug cloudflare#4: double-counting in result.skipped when AbortController fires and
  res.text() throws — fix: replace await res.text() with res.body?.cancel()
- Bug cloudflare#6: dynamic routes without getStaticPaths/generateStaticParams classified
  as 'ssr' — fix: use 'unknown' (skipped for unenumerable params, not SSR APIs)
- Bug cloudflare#3: routes that throw in ssrLoadModule silently omitted from
  routeClassifications — fix: wrap in try/catch, add 'unknown' classification
- Bug cloudflare#5: buildReportRows ignored knownRoutes for API routes — fix: check
  known?.get(route.pattern) first, fall back to 'api'
- Bug cloudflare#7: dead !Array.isArray guard after try/catch in expandDynamicAppRoute
  — remove unreachable branch
- Bug cloudflare#8: middlewareHeaders spread onto 200 pre-rendered response could include
  Location header — fix: filter out 'location' before spreading
- Bug cloudflare#9: configOverride typed as Partial<NextConfig> allows unsafe non-scalar
  fields — narrow to Pick<NextConfig, 'output' | 'trailingSlash'>
NathanDrake2406 added a commit to NathanDrake2406/vinext that referenced this pull request Mar 16, 2026
james-elicx pushed a commit that referenced this pull request Mar 16, 2026
* Add production coverage for global-error compat

* Address global-error review feedback

* docs: update tracker notes for tests #3 and #4 to reflect production preview coverage
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