#8280 @cloudflare/vitest-pool-workers deals with `foo.wasm.js` as a wasm module
Maintainer-confirmed bug: glob-to-regexp dependency doesn't anchor patterns with $, causing *.wasm to match foo.wasm.js. No fix merged in ~11 months despite quick win and vitest:priority labels.
Implement fix: replace glob-to-regexp or add $ anchors to pattern regexes for proper end-of-string matching.
Analysis Report
Issue #8280: @cloudflare/vitest-pool-workers deals with foo.wasm.js as a wasm module
Summary
| Field | Value |
|---|---|
| Issue | #8280 |
| Title | @cloudflare/vitest-pool-workers deals with foo.wasm.js as a wasm module |
| State | OPEN |
| Created | 2025-02-27 |
| Updated | 2025-10-30 |
| Labels | bug, quick win, vitest, vitest:priority |
| Reporter | miyaji255 |
Problem Description
The @cloudflare/vitest-pool-workers package incorrectly treats JavaScript files containing .wasm anywhere in their filename (e.g., main.wasm.test.js) as WebAssembly modules. This causes the test runner to fail with a module loading error because it attempts to load the JavaScript file as a compiled WebAssembly module.
Error Message
Error: No such module "D:/Users/.../src/main.wasm.test.js?mf_vitest_force=CompiledWasm"
The ?mf_vitest_force=CompiledWasm query parameter indicates the file is being incorrectly identified as a WebAssembly module.
Root Cause Analysis
Maintainer-confirmed bug (petebacondarwin on 2025-02-27):
The issue is caused by a shortcoming in the glob-to-regexp dependency. The library doesn't add $ to the end of the regexes it generates, causing patterns like *.wasm to match not just foo.wasm but also foo.wasm.js, foo.wasm.test.ts, etc.
The pattern matching is too permissive because:
- Pattern
*.wasmgenerates a regex that matches "contains .wasm" rather than "ends with .wasm" - The
glob-to-regexplibrary has been abandoned for several years
Current Status
- Confirmed bug with identified root cause
- No fix merged - the issue remains open
- Labeled as
quick win- indicating it should be straightforward to fix - Labeled as
vitest:priority- indicating priority within vitest issues
Related PRs
- PR #11094 (OPEN): "[vitest-pool-workers] Allow
.wasmfiles to be imported as.wasm?module" - different issue but same area of code
Possible Solutions (from maintainer comment)
- Replace
glob-to-regexpwithglob-regexpackage - Vendor the
glob-to-regexpcode and fix it to add$anchors
Note: In v0.12.4, glob-to-regexp was bundled into miniflare but the underlying bug was not fixed.
Reproduction
- Minimal reproduction provided: https://github.com/miyaji255/wasmjs-error
- Versions reported: wrangler 3.110.0, vitest 3.0.7, @cloudflare/vitest-pool-workers 0.7.3
Recommendation
KEEP OPEN
Reasoning
- Confirmed bug - Maintainer confirmed this is a bug with clear root cause
- No fix merged - Issue has been open ~11 months with no resolution
- Labeled priority - Has
vitest:priorityandquick winlabels - Clear solution path - Maintainer identified two possible fixes
- Good reproduction - Reporter provided minimal reproduction repo
Suggested Action
Implement the fix by either:
- Replacing
glob-to-regexpwith a properly maintained alternative that correctly anchors patterns - Adding
$anchors to the generated regexes where patterns should match at end-of-string
The fix should ensure that module type detection patterns like *.wasm only match files that actually end with .wasm, not files that contain .wasm anywhere in their path.
Difficulty
Easy - The root cause is identified and the fix is localized to pattern matching logic.
Version Information
| Package | Report Version | Current Version |
|---|---|---|
| wrangler | 3.110.0 | 4.60.0 |
| @cloudflare/vitest-pool-workers | 0.7.3 | 0.12.6 |
| vitest | 3.0.7 | current |
Report generated: 2026-01-25
Notes & Feedback (0)
No notes yet.