You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When importing knex, a CJS module importing debug, an error is thrown: Cannot use require() to import an ES Module.
This is because require('debug') resolves to @cloudflare/vitest-pool-workers/dist/worker/lib/debug.mjs, due to these lines:
hansottowirtz
changed the title
🐛 BUG: require('debug') resolves to @cloudflare/vitest-pool-workers/dist/worker/lib/debug.mjs` instead of to the correct file
🐛 BUG: require('debug') resolves to @cloudflare/vitest-pool-workers/dist/worker/lib/debug.mjs instead of to the correct file
Aug 2, 2024
Which Cloudflare product(s) does this pertain to?
Workers Vitest Integration
What version(s) of the tool(s) are you using?
0.4.17
What version of Node are you using?
20
What operating system and version are you using?
macOS Sonoma 14.5
Describe the Bug
Observed behavior
When importing
knex
, a CJS module importingdebug
, an error is thrown: Cannot use require() to import an ES Module.This is because
require('debug')
resolves to@cloudflare/vitest-pool-workers/dist/worker/lib/debug.mjs
, due to these lines:workers-sdk/packages/vitest-pool-workers/src/pool/module-fallback.ts
Lines 318 to 337 in eb6f249
This results in a redirect:
Expected behavior
The file should resolve to the correct module.
Steps to reproduce
Make a worker with
import Knex from "knex"
, and use it in a Vitest test.Please provide a link to a minimal reproduction
https://github.com/hansottowirtz/workers-sdk-require-debug-repro
Please provide any relevant error logs
No response
The text was updated successfully, but these errors were encountered: