fix: apply cjs interop for truthy __esModule - #10363
sheremet-va merged 3 commits into
Conversation
✅ Deploy Preview for vitest-dev ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
__esModule__esModule
|
I don’t think we should change the behavior for bun. The interop is applied because Node cannot handle it specifically. deps.interopDefault is not required for bun at all, I think. It might be better to just disable it in that runtime |
Testing |
|
I’m not stopping the merge, I just want to discuss this first
Why isn’t it intended? One use case I see is proxies throwing errors (I think this is why it’s “in” right now) |
|
Checking Like this code and also some snippet in Vite also hasm.__esModule ? ... style.
|
|
Ok, I don't have a strong case against it, although I still believe for bun we should just change the default since it's not required in that environment. |
vitest 4.1.7 testa `'__esModule' in mod` em vez de truthiness, e o Bun
deixa a propriedade presente mas undefined → `import { z } from 'zod'`
resolve para undefined dentro do node-symlinked-to-bun do oven/bun:1.3-debian.
Mac usa node real, por isso só o CI falha.
Corrigido upstream em vitest-dev/vitest#10363 (mergeado 2026-05-18),
ainda não disponível em stable. 5.0.0-beta.3 inclui o fix.
Falha original: 5 test files do products/menu (`z.object`/`z.enum` undefined)
em git.iedora.com/eduvhc/iedora/actions/runs/8/jobs/40.
Description
As written in #10359 (comment), Bun defines
__esModuleexport for genuine esm in a way'__esModule' in mod === truebutmod.__esModule === undefined. This behavior is Bun specific quirk, but Vitest applying interop based on__esModuleproperty existence seems less conventional and can be naturally mitigated on Vitest side by detecting truthy__esModule. That's what PR changes.Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
pnpm-lock.yamlunless you introduce a new test example.Tests
pnpm test:ci.Documentation
pnpm run docscommand.Changesets
feat:,fix:,perf:,docs:, orchore:.