mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #296] [MERGED] fix: set consumer: 'client' on client environment to fix Nitro ERR_UNSUPPORTED_ESM_URL_SCHEME #454
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#454
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?
📋 Pull Request Information
Original PR: https://github.com/cloudflare/vinext/pull/296
Author: @ask-bonk[bot]
Created: 3/6/2026
Status: ✅ Merged
Merged: 3/7/2026
Merged by: @southpolesteve
Base:
main← Head:opencode/issue260-20260306041426📝 Commits (1)
9d3dff8fix: set consumer: 'client' on client environment to fix Nitro ERR_UNSUPPORTED_ESM_URL_SCHEME📊 Changes
1 file changed (+8 additions, -0 deletions)
View changed files
📝
packages/vinext/src/index.ts(+8 -0)📄 Description
Summary
Fixes #260
consumer: "client"on the client environment config so Nitro'sconfigEnvironmenthook can identify it before Vite applies default valuesRoot Cause
When Nitro's
configEnvironmenthook runs for each Vite environment, it checksconfig.consumer === "client"to skip client environments. However, Vite only defaultsconsumerto"client"for the"client"environment during config resolution — which happens after allconfigEnvironmenthooks. Without an explicitconsumer: "client"in vinext's environment config, Nitro seesconsumerasundefinedand incorrectly treats the client environment as a server-side service.This causes Nitro to create a
FetchableDevEnvironmentfor the client environment and loadvirtual:vinext-app-browser-entryin a Node.js worker thread. The browser entry imports@vitejs/plugin-rsc/browser, which Vite'sfetchModuleexternalizes (it's a bare specifier). Node.js then natively loadsbrowser.js, which containsimport * as clientReferences from "virtual:vite-rsc/client-references"— and Node's ESM loader throwsERR_UNSUPPORTED_ESM_URL_SCHEMEbecausevirtual:is not a supported protocol.Verification
pnpm run devinexamples/app-router-nitroshows the errorConfiguring client environmentinstead ofAuto-detected service "client"🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.