-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
What versions & operating system are you using?
wrangler@4.22.0, @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 requireing JSON files.
(like here: https://unpkg.com/ajv@8.17.1/dist/core.js)
This works when we do wrangler dev or vite dev, but fails when we run vitest.
Repro
npm install && npm testEither 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
Labels
Type
Projects
Status