Skip to content

Commit 076c71a

Browse files
committed
feat(vite-plugin-cloudflare): disable rsc server handler by default
1 parent 10a1c4a commit 076c71a

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@cloudflare/vite-plugin": minor
3+
---
4+
5+
Set `{ serverHandler: false }` automatically when using `@vitejs/plugin-rsc`
6+
7+
By default, `@vitejs/plugin-rsc` adds dev and preview server middleware that imports the RSC entry in Node.js. This fails with `cloudflare:*` imports (`ERR_UNSUPPORTED_ESM_URL_SCHEME`) and is unnecessary since the Cloudflare plugin handles requests via workerd. Users no longer need to pass `rsc({ serverHandler: false })` manually.

packages/vite-plugin-cloudflare/src/plugins/config.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ export const configPlugin = createPlugin("config", (ctx) => {
2121
return {
2222
config(userConfig, env) {
2323
if (ctx.resolvedPluginConfig.type === "preview") {
24-
return { appType: "custom" };
24+
return {
25+
appType: "custom",
26+
rsc: { serverHandler: false },
27+
};
2528
}
2629

2730
if (!ctx.hasShownWorkerConfigWarnings) {
@@ -43,6 +46,7 @@ export const configPlugin = createPlugin("config", (ctx) => {
4346

4447
return {
4548
appType: "custom",
49+
rsc: { serverHandler: false },
4650
server: {
4751
fs: {
4852
deny: [...defaultDeniedFiles, ".dev.vars", ".dev.vars.*"],

0 commit comments

Comments
 (0)