Import condition resolution wrong per Vite environment (`react-server`, `edge-light`, `browser`)
#1,356 opened on 2026年5月20日
Repository metrics
- Stars
- (8,120 stars)
- PR merge metrics
- (平均マージ 1d 1h) (30d で 462 merged PRs)
説明
This issue was created by an agent analysing CI failures from the Next.js Deploy Suite (vinext
mainvs Next.jsv16.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-servercondition - Edge runtime: Should resolve
edge-lightcondition - Client/browser: Should resolve
browsercondition - SSR/Node: Should resolve
nodecondition
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
-
Reproduce first in vinext's own test suite. Add a test with a package that has different
exportsconditions (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. -
Study how conditions are configured per environment. Check
resolve.conditionsin 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", ...]. -
Fix the Vite plugin's environment configuration. In the vinext Vite plugin (
index.ts), ensure each environment'sresolve.conditionsarray includes the correct conditions for that context.