Closed AdiRishi closed 1 month ago
Thank you for creating the issue. I tested the following versions but encountered the same error:
I hope for a resolution to this issue.
I have the same problem
Hey, I had a look at your repro and it seems like vitest will work if you change your config to:
deps: {
inline: ['@clerk/backend', 'snakecase-keys', 'snake-case'],
}
Let me know if you're still having issues :)
@emily-shen thank you so much!
I can't believe I didn't think to include the actual @clerk/backend
package in deps.inline
🤦
Your fix absolutely works 😄 . I'll close this issue out 💥 .
For anyone worried about the vitest deprecation warning that comes with using deps.inline
, you can achieve the same effect with server.deps.inline
server: {
deps: {
inline: ['@clerk/backend', 'snakecase-keys', 'snake-case'],
},
},
I've been following this and will have to see if including more in the inline deps fixes the same issue with hono.
Which Cloudflare product(s) does this pertain to?
Workers Vitest Integration
What version(s) of the tool(s) are you using?
3.78.2 [wrangler], 0.5.2 [vitest-pool-workers]
What version of Node are you using?
20.17.0
What operating system and version are you using?
Mac Sonoma 14.6.1 (23G93)
Describe the Bug
Observed behavior
When using the
@clerk/backend
package and@cloudflare/vitest-pool-workers
tests do not run successfully. The reported error isTypeError: Cannot use require() to import an ES Module.
and it happens because of thesnakecase-keys
module that clerk uses.It is worth noting that this error does not stop the actual worker from functioning, esbuild is able to handle this when building and deploying this worker.
I did try to solve this by using
deps.inline
however this didn't work either.Expected behavior
I'm no expert in JS bundlers but I feel like this should be a solvable problem? Otherwise we are severly limited in what deps we can use when working with Cloudflare workers.
Please provide a link to a minimal reproduction
https://github.com/AdiRishi/vitest-pool-esm-bug
Please provide any relevant error logs