What versions & operating system are you using?
System:
OS: macOS 26.5.2
CPU: (8) arm64 Apple M1
Memory: 142.52 MB / 8.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 24.18.0 - /Users/jeremy/.nodenv/versions/24.18.0/bin/node
Yarn: 1.22.22 - /opt/homebrew/bin/yarn
npm: 11.16.0 - /Users/jeremy/.nodenv/versions/24.18.0/bin/npm
pnpm: 11.17.0 - /opt/homebrew/bin/pnpm
Deno: 2.9.3 - /opt/homebrew/bin/deno
npmPackages:
@cloudflare/vite-plugin: ^1.47.0 => 1.47.0
wrangler: ^4.114.0 => 4.114.0
Please provide a link to a minimal reproduction
https://github.com/jeremy-code/cloudflare-vite-vitest
Describe the Bug
Steps to reproduce
- Create Vite config with
@cloudflare/vite-plugin
- Create Vitest config extending Vite config using Vitest browser mode
- Attempt to run
vitest
This only occurs in browser mode. In the minimal reproduction, the error logged is "module is not defined".
FWIW, though I could not reproduce it, on a different project, I receive the error: TypeError: Cannot read properties of undefined (reading 'wrapDynamicImport') with the same error stack. See also: withastro/astro#16275, vitest-dev/vitest#10319, sveltejs/kit#14149
Please provide any relevant error logs
$ vitest --run
⎯⎯⎯⎯⎯⎯⎯ Startup Error ⎯⎯⎯⎯⎯⎯⎯⎯
ReferenceError: module is not defined
at runInRunnerObject (workers/runner-worker/index.js:107:3)
at getWorkerEntryExportTypes (workers/runner-worker/index.js:246:24)
at null.<anonymous> (workers/runner-worker/index.js:350:37)
at maybeCaptureError (workers/runner-worker/index.js:51:10) {
[cause]: undefined
}
[ELIFECYCLE] Test failed. See above for more details.
What versions & operating system are you using?
Please provide a link to a minimal reproduction
https://github.com/jeremy-code/cloudflare-vite-vitest
Describe the Bug
Steps to reproduce
@cloudflare/vite-pluginvitestThis only occurs in browser mode. In the minimal reproduction, the error logged is "module is not defined".
FWIW, though I could not reproduce it, on a different project, I receive the error:
TypeError: Cannot read properties of undefined (reading 'wrapDynamicImport')with the same error stack. See also: withastro/astro#16275, vitest-dev/vitest#10319, sveltejs/kit#14149Please provide any relevant error logs
$ vitest --run ⎯⎯⎯⎯⎯⎯⎯ Startup Error ⎯⎯⎯⎯⎯⎯⎯⎯ ReferenceError: module is not defined at runInRunnerObject (workers/runner-worker/index.js:107:3) at getWorkerEntryExportTypes (workers/runner-worker/index.js:246:24) at null.<anonymous> (workers/runner-worker/index.js:350:37) at maybeCaptureError (workers/runner-worker/index.js:51:10) { [cause]: undefined } [ELIFECYCLE] Test failed. See above for more details.