[GH-ISSUE #325] [ERROR] Could not resolve "virtual:vinext-rsc-entry" #75

Closed
opened 2026-05-06 12:37:00 +02:00 by BreizhHardware · 5 comments

Originally created by @modlin-aurena on GitHub (Mar 7, 2026).
Original GitHub issue: https://github.com/cloudflare/vinext/issues/325

I am currently trying to migrate my project from using OpenNext to vinext for Cloudflare Workers deployment.

The Worker successfully builds the app using vinext deploy but fails at the end because of this error.

2026-03-07T16:19:03.984Z	  Deploying to production...
2026-03-07T16:19:06.473Z	Error: Command failed: /opt/buildhome/repo/node_modules/.bin/wrangler deploy
2026-03-07T16:19:06.474Z	✘ [ERROR] Build failed with 1 error:
2026-03-07T16:19:06.474Z	
2026-03-07T16:19:06.474Z	  ✘ [ERROR] Could not resolve "virtual:vinext-rsc-entry"
2026-03-07T16:19:06.474Z	  
2026-03-07T16:19:06.474Z	      node_modules/vinext/dist/server/app-router-entry.js:15:23:
2026-03-07T16:19:06.474Z	        15 │ import rscHandler from "virtual:vinext-rsc-entry";
2026-03-07T16:19:06.474Z	           ╵                        ~~~~~~~~~~~~~~~~~~~~~~~~~~
2026-03-07T16:19:06.474Z	  
2026-03-07T16:19:06.474Z	    You can mark the path "virtual:vinext-rsc-entry" as external to exclude it from the bundle, which will remove this error and leave the unresolved path in the bundle.

This is my next.config.mjs

// next.config.mjs
/** @type {import('next').NextConfig} */
export default {
	productionBrowserSourceMaps: false,
	allowedDevOrigins: ["*"],
	transpilePackages: ["@modlin/ui"],
}

This is my vite.config.ts

// vite.config.ts
import vinext from "vinext"
import { defineConfig } from "vite"

export default defineConfig({
	plugins: [vinext()],
	build: {
		sourcemap: false,
	},
})

This is my wrangler.jsonc

{
    "$schema": "./node_modules/wrangler/config-schema.json",
    "name": "web",
    "main": "./worker/index.ts",
    "compatibility_date": "2026-03-07",
    "compatibility_flags": ["nodejs_compat"],
    "assets": {
        "directory": "dist/client",
        "not_found_handling": "none",
        "binding": "ASSETS"
    },
    "images": {
        "binding": "IMAGES"
    },
    "upload_source_maps": false,
}

This is my package.json

{
	"$schema": "https://json.schemastore.org/package",
	"name": "web",
	"version": "0.1.0",
	"dependencies": {
		"@modlin/ui": "latest",
		"next": "^16.1.6",
		"react": "^19.2.4",
		"react-dom": "^19.2.4",
		"vinext": "^0.0.23",
	},
	"private": true,
	"scripts": {
		"dev": "vinext dev",
		"build": "vinext build",
		"start": "vinext start",
		"deploy": "vinext deploy",
		"lint": "biome check",
		"format": "biome format --write",
	},
	"type": "module",
	"devDependencies": {
		"@cloudflare/vite-plugin": "^1.26.1",
		"@tailwindcss/postcss": "^4.2.1",
		"@types/bun": "^1.3.9",
		"@types/node": "^25.3.0",
		"@types/react": "^19.2.14",
		"@types/react-dom": "^19.2.3",
		"@vitejs/plugin-rsc": "^0.5.21",
		"postcss": "^8.5.6",
		"tailwindcss": "^4.2.1",
		"typescript": "^5.9.3",
		"vite": "^7.3.1",
		"wrangler": "^4.68.0"
	}
}

Please help me and if you need more context please feel free to ask me.

Originally created by @modlin-aurena on GitHub (Mar 7, 2026). Original GitHub issue: https://github.com/cloudflare/vinext/issues/325 I am currently trying to migrate my project from using OpenNext to vinext for Cloudflare Workers deployment. The Worker successfully builds the app using `vinext deploy` but fails at the end because of this error. ``` 2026-03-07T16:19:03.984Z Deploying to production... 2026-03-07T16:19:06.473Z Error: Command failed: /opt/buildhome/repo/node_modules/.bin/wrangler deploy 2026-03-07T16:19:06.474Z ✘ [ERROR] Build failed with 1 error: 2026-03-07T16:19:06.474Z 2026-03-07T16:19:06.474Z ✘ [ERROR] Could not resolve "virtual:vinext-rsc-entry" 2026-03-07T16:19:06.474Z 2026-03-07T16:19:06.474Z node_modules/vinext/dist/server/app-router-entry.js:15:23: 2026-03-07T16:19:06.474Z 15 │ import rscHandler from "virtual:vinext-rsc-entry"; 2026-03-07T16:19:06.474Z ╵ ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2026-03-07T16:19:06.474Z 2026-03-07T16:19:06.474Z You can mark the path "virtual:vinext-rsc-entry" as external to exclude it from the bundle, which will remove this error and leave the unresolved path in the bundle. ``` This is my next.config.mjs ```js // next.config.mjs /** @type {import('next').NextConfig} */ export default { productionBrowserSourceMaps: false, allowedDevOrigins: ["*"], transpilePackages: ["@modlin/ui"], } ``` This is my vite.config.ts ```ts // vite.config.ts import vinext from "vinext" import { defineConfig } from "vite" export default defineConfig({ plugins: [vinext()], build: { sourcemap: false, }, }) ``` This is my wrangler.jsonc ```js { "$schema": "./node_modules/wrangler/config-schema.json", "name": "web", "main": "./worker/index.ts", "compatibility_date": "2026-03-07", "compatibility_flags": ["nodejs_compat"], "assets": { "directory": "dist/client", "not_found_handling": "none", "binding": "ASSETS" }, "images": { "binding": "IMAGES" }, "upload_source_maps": false, } ``` This is my package.json ```json { "$schema": "https://json.schemastore.org/package", "name": "web", "version": "0.1.0", "dependencies": { "@modlin/ui": "latest", "next": "^16.1.6", "react": "^19.2.4", "react-dom": "^19.2.4", "vinext": "^0.0.23", }, "private": true, "scripts": { "dev": "vinext dev", "build": "vinext build", "start": "vinext start", "deploy": "vinext deploy", "lint": "biome check", "format": "biome format --write", }, "type": "module", "devDependencies": { "@cloudflare/vite-plugin": "^1.26.1", "@tailwindcss/postcss": "^4.2.1", "@types/bun": "^1.3.9", "@types/node": "^25.3.0", "@types/react": "^19.2.14", "@types/react-dom": "^19.2.3", "@vitejs/plugin-rsc": "^0.5.21", "postcss": "^8.5.6", "tailwindcss": "^4.2.1", "typescript": "^5.9.3", "vite": "^7.3.1", "wrangler": "^4.68.0" } } ``` Please help me and if you need more context please feel free to ask me.
Author
Owner

@Divkix commented on GitHub (Mar 7, 2026):

Hey — thanks for the report. The error is because your vite.config.ts is missing the @cloudflare/vite-plugin. Without it, Vite doesn't process the worker entry through its build pipeline, so wrangler's esbuild tries to bundle it directly and chokes on the virtual:vinext-rsc-entry import (which only the vinext Vite plugin can resolve).

You already have @cloudflare/vite-plugin in your devDependencies — you just need to use it. Update your vite.config.ts to:

import vinext from "vinext"
import { cloudflare } from "@cloudflare/vite-plugin"
import { defineConfig } from "vite"

export default defineConfig({
  plugins: [
    vinext(),
    cloudflare({
      viteEnvironment: {
        name: "rsc",
        childEnvironments: ["ssr"],
      },
    }),
  ],
  build: {
    sourcemap: false,
  },
})

The cloudflare() plugin tells Vite to also build the worker entry through Vite's pipeline, where vinext resolves the virtual modules. Without it, wrangler falls back to its own bundler which has no idea what virtual:vinext-rsc-entry is.

vinext deploy already warns about this (it detects when an existing vite config is missing the cloudflare plugin), but the warning is easy to miss since it doesn't halt the build. We'll be upgrading that to a hard error so this is caught earlier.

Let us know if that fixes it.

<!-- gh-comment-id:4017072867 --> @Divkix commented on GitHub (Mar 7, 2026): Hey — thanks for the report. The error is because your `vite.config.ts` is missing the `@cloudflare/vite-plugin`. Without it, Vite doesn't process the worker entry through its build pipeline, so wrangler's esbuild tries to bundle it directly and chokes on the `virtual:vinext-rsc-entry` import (which only the vinext Vite plugin can resolve). You already have `@cloudflare/vite-plugin` in your devDependencies — you just need to use it. Update your `vite.config.ts` to: ```ts import vinext from "vinext" import { cloudflare } from "@cloudflare/vite-plugin" import { defineConfig } from "vite" export default defineConfig({ plugins: [ vinext(), cloudflare({ viteEnvironment: { name: "rsc", childEnvironments: ["ssr"], }, }), ], build: { sourcemap: false, }, }) ``` The `cloudflare()` plugin tells Vite to also build the worker entry through Vite's pipeline, where vinext resolves the virtual modules. Without it, wrangler falls back to its own bundler which has no idea what `virtual:vinext-rsc-entry` is. `vinext deploy` already warns about this (it detects when an existing vite config is missing the cloudflare plugin), but the warning is easy to miss since it doesn't halt the build. We'll be upgrading that to a hard error so this is caught earlier. Let us know if that fixes it.
Author
Owner

@pablohenriqueop commented on GitHub (Mar 8, 2026):

Hey — thanks for the report. The error is because your vite.config.ts is missing the @cloudflare/vite-plugin. Without it, Vite doesn't process the worker entry through its build pipeline, so wrangler's esbuild tries to bundle it directly and chokes on the virtual:vinext-rsc-entry import (which only the vinext Vite plugin can resolve).

You already have @cloudflare/vite-plugin in your devDependencies — you just need to use it. Update your vite.config.ts to:

import vinext from "vinext"
import { cloudflare } from "@cloudflare/vite-plugin"
import { defineConfig } from "vite"

export default defineConfig({
plugins: [
vinext(),
cloudflare({
viteEnvironment: {
name: "rsc",
childEnvironments: ["ssr"],
},
}),
],
build: {
sourcemap: false,
},
})
The cloudflare() plugin tells Vite to also build the worker entry through Vite's pipeline, where vinext resolves the virtual modules. Without it, wrangler falls back to its own bundler which has no idea what virtual:vinext-rsc-entry is.

vinext deploy already warns about this (it detects when an existing vite config is missing the cloudflare plugin), but the warning is easy to miss since it doesn't halt the build. We'll be upgrading that to a hard error so this is caught earlier.

Let us know if that fixes it.

Thanks, your suggestion works in my app.

<!-- gh-comment-id:4017958809 --> @pablohenriqueop commented on GitHub (Mar 8, 2026): > Hey — thanks for the report. The error is because your `vite.config.ts` is missing the `@cloudflare/vite-plugin`. Without it, Vite doesn't process the worker entry through its build pipeline, so wrangler's esbuild tries to bundle it directly and chokes on the `virtual:vinext-rsc-entry` import (which only the vinext Vite plugin can resolve). > > You already have `@cloudflare/vite-plugin` in your devDependencies — you just need to use it. Update your `vite.config.ts` to: > > import vinext from "vinext" > import { cloudflare } from "@cloudflare/vite-plugin" > import { defineConfig } from "vite" > > export default defineConfig({ > plugins: [ > vinext(), > cloudflare({ > viteEnvironment: { > name: "rsc", > childEnvironments: ["ssr"], > }, > }), > ], > build: { > sourcemap: false, > }, > }) > The `cloudflare()` plugin tells Vite to also build the worker entry through Vite's pipeline, where vinext resolves the virtual modules. Without it, wrangler falls back to its own bundler which has no idea what `virtual:vinext-rsc-entry` is. > > `vinext deploy` already warns about this (it detects when an existing vite config is missing the cloudflare plugin), but the warning is easy to miss since it doesn't halt the build. We'll be upgrading that to a hard error so this is caught earlier. > > Let us know if that fixes it. Thanks, your suggestion works in my app.
Author
Owner

@Divkix commented on GitHub (Mar 8, 2026):

Btw, we can add a feature which fails the build if cloudflare() is not there.

<!-- gh-comment-id:4018019859 --> @Divkix commented on GitHub (Mar 8, 2026): Btw, we can add a feature which fails the build if `cloudflare()` is not there.
Author
Owner

@james-elicx commented on GitHub (Mar 8, 2026):

I did add a warning in the deploy command but failing sounds reasonable as well 👍

<!-- gh-comment-id:4018694242 --> @james-elicx commented on GitHub (Mar 8, 2026): I did add a warning in the deploy command but failing sounds reasonable as well 👍
Author
Owner

@modlin-aurena commented on GitHub (Mar 8, 2026):

@pablohenriqueop Thank you for the solution, I did already figure it out but it does come with concerns regarding local development as I wasn't able to use vinext dev so I use next dev as of now instead.

<!-- gh-comment-id:4019315642 --> @modlin-aurena commented on GitHub (Mar 8, 2026): @pablohenriqueop Thank you for the solution, I did already figure it out but it does come with concerns regarding local development as I wasn't able to use `vinext dev` so I use `next dev` as of now instead.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vinext#75
No description provided.