cloudflare / cloudflare/workers-sdk

__filename not defined on dev with vite-plugin

Open
#9,027 23 comments 2 reactions 1 assignee Claimed by @petebacondarwin View on GitHub
package:vite-plugin
Dominant language
TypeScript
Stars
4.5k
Forks
1.5k
Avg merge
3d 8h
Merged PRs (30d)
186

Description

### Which Cloudflare product(s) does this pertain to?

Vite Plugin

### What versions & operating system are you using?

Wrangler v4.12.0, Node v22.14.0, Vite Plugin v1.0.9

### Please provide a link to a minimal reproduction

https://github.com/erictaylor/cloudflare-vite-plugin-bug

### Describe the Bug

When running `react-router dev` with a `@cloudflare/vite-plugin` setup I get the following error:

```
[vite] Internal server error: __filename is not defined
at async ProxyServer.fetch (file:///Users/erictaylor/[redacted]/node_modules/.pnpm/miniflare@4.20250417.0_bufferutil@4.0.9_utf-8-validate@5.0.10/node_modules/miniflare/src/workers/core/proxy.worker.ts:173:11)
```

However, I don't have any issues with preview or deployed builds. Everything works as expected in those cases, so the issue is only present on the development server.

### Please provide any relevant error logs

_No response_

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.