Description
What versions & operating system are you using?
[email protected], @cloudflare/vitest-pool-workers
Please provide a link to a minimal reproduction
https://github.com/threepointone/test-vitest-workers-json-require
Describe the Bug
A require
of a JSON file (NOT an import
) will fail to run with @cloudflare/vitest-pool-workers
, with a cryptic error message SyntaxError: Unexpected token ':'
.
Why is this important? Sure, developers might use import
to import JSON files, but third party dependencies (like the very popular ajv
) do cjs builds, which end up require
ing JSON files.
(like here: https://unpkg.com/[email protected]/dist/core.js)
This works when we do wrangler dev or vite dev, but fails when we run vitest
.
Repro
npm install && npm test
Either we should make it work with vitest/vitest-pool-workers, or we should have a better error.
Workaround:
add it to the deps
section of vitest.config.ts
Please provide any relevant error logs
No response
Metadata
Metadata
Assignees
Type
Projects
Status