Describe the bug
Since Vite 8.0.16 (also 7.3.5 and 6.4.3), a test in jsdom or happy-dom can't import a module whose path contains a colon:
Error: Cannot find module '/src/route:name/index.ts' imported from <root>/test/jsdom.test.ts
The same import works in node, and it works in the browser through Vite's dev server.
I ran into this with Laravel Wayfinder, which names route directories after route names (routes/company:logo/index.ts). Our tests passed on Vitest 2, which bundles Vite 5.4. After upgrading to Vitest 5, every component test that imports such a route failed.
From what I can tell, the cause is vitejs/vite#22572 (GHSA-fx2h-pf6j-xcff). It made isFileLoadingAllowed reject any path that contains : while server.fs.strict is on. The dev server still loads static imports, because import analysis pre-transforms them with warmupRequest, which skips the check. Vitest sets preTransformRequests = false, so each fetch in the client environment runs the check. The ssr environment skips it, which is why node passes.
For now I work around it with server.fs.strict: false when running under Vitest. I'd like to send a PR with a fix.
I used Claude Code to help track this down and write it up.
Reproduction
https://github.com/ragulka/vitest-colon-path-repro
test/node.test.ts passes. test/jsdom.test.ts and test/happy-dom.test.ts fail.
System Info
System:
OS: macOS 27.0.1
CPU: (10) arm64 Apple M1 Max
Memory: 213.03 MB / 64.00 GB
Shell: 5.9
Binaries:
Node: 22.22.2
Yarn: 1.22.19
npm: 10.9.7
pnpm: 10.33.4
Deno: 2.7.1
Browsers:
Brave Browser: 153.1.95.101
Chrome: 154.0.8037.92
Firefox: 123.0.1
Firefox Developer Edition: 153.0
Safari: 27.0.1
npmPackages:
vite: 8.2.1 => 8.2.1
vitest: 5.0.3 => 5.0.3
Used Package Manager
pnpm
Validations
Describe the bug
Since Vite 8.0.16 (also 7.3.5 and 6.4.3), a test in
jsdomorhappy-domcan't import a module whose path contains a colon:The same import works in
node, and it works in the browser through Vite's dev server.I ran into this with Laravel Wayfinder, which names route directories after route names (
routes/company:logo/index.ts). Our tests passed on Vitest 2, which bundles Vite 5.4. After upgrading to Vitest 5, every component test that imports such a route failed.From what I can tell, the cause is vitejs/vite#22572 (GHSA-fx2h-pf6j-xcff). It made
isFileLoadingAllowedreject any path that contains:whileserver.fs.strictis on. The dev server still loads static imports, because import analysis pre-transforms them withwarmupRequest, which skips the check. Vitest setspreTransformRequests = false, so each fetch in theclientenvironment runs the check. Thessrenvironment skips it, which is whynodepasses.For now I work around it with
server.fs.strict: falsewhen running under Vitest. I'd like to send a PR with a fix.I used Claude Code to help track this down and write it up.
Reproduction
https://github.com/ragulka/vitest-colon-path-repro
pnpm install pnpm testtest/node.test.tspasses.test/jsdom.test.tsandtest/happy-dom.test.tsfail.System Info
Used Package Manager
pnpm
Validations