Description
In the recent collaborator summit, one thing that many people mentioned as a blocker for ESM migration was Jest support for ESM. I noticed that Vitest claims to be both “Jest compatible” and to have “out-of-the-box ESM” support. I joined their Discord server to ask what was lacking from Node from their perspective, for them to provide as good an experience in ESM as Jest does in CommonJS: https://discord.com/channels/917386801235247114/918057929670811708/998630895110066226. @sheremet-va answered my questions. The issues mentioned were:
-
Being able to set
--conditions
dynamically at runtime, since Vitest users define these in configuration files (applies to CommonJS too; I encouraged them to open an issue). -
Spawning workers is slow.
-
The
node:vm
support for ESM is still experimental. Currently Vitest transpiles code to CommonJS and runs it through the stablevm
API, so they already have a workaround; but presumably it would be nice to not need to transpile if possible. Vitest will always need to do some specifier rewriting as part of its mission (like to do mocks) so it would be only a minor improvement to not need to also convertimport
torequire
.
So basically we’re already at parity, though there’s still room for improvement. Regarding the last point, I think Jest currently takes the approach of using the experimental API, which is a pain point for users. If anyone from that team thinks of other issues I’ll update this list.