cloudflare / cloudflare/vinext

Import condition resolution wrong per Vite environment (`react-server`, `edge-light`, `browser`)

Open
#1,356 2 comments 0 reactions 0 assignees View on GitHub
adapter-api-e2e help wanted
Dominant language
TypeScript
Stars
8.8k
Forks
406
Avg merge
2d 6h
Merged PRs (30d)
120

Description

> *This issue was created by an agent analysing CI failures from the [Next.js Deploy Suite](https://github.com/cloudflare/vinext/actions/runs/26163751905) (vinext `main` vs Next.js `v16.2.6`, 2026-05-20).*

## Problem

Vite import conditions (`react-server`, `edge-light`, `browser`) are not being set correctly per environment. Package `exports` conditions should resolve differently depending on which Vite environment is doing the importing:

- **RSC environment:** Should resolve `react-server` condition
- **Edge runtime:** Should resolve `edge-light` condition
- **Client/browser:** Should resolve `browser` condition
- **SSR/Node:** Should resolve `node` condition

Tests show that conditions like `react-server` resolve to `null` when they should have a value, and `edge-light` resolves as `node` instead.

## Estimated Impact

~11 test failures.

## Affected Test Suites

- `test/e2e/import-conditions/import-conditions.test.ts` (11 failures)

## Recommendation

1. **Reproduce first in vinext's own test suite.** Add a test with a package that has different `exports` conditions (e.g., `react-server`, `edge-light`, `browser`, `node`) and verify the correct export is resolved in each environment. Confirm the wrong condition is being used.

2. **Study how conditions are configured per environment.** Check `resolve.conditions` in the Vite config for each environment (RSC, SSR, client). The RSC environment needs `["react-server", ...]`, edge environments need `["edge-light", "worker", ...]`, and client needs `["browser", ...]`.

3. **Fix the Vite plugin's environment configuration.** In the vinext Vite plugin (`index.ts`), ensure each environment's `resolve.conditions` array includes the correct conditions for that context.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.