Closed akx closed 3 years ago
p-queue
does not use main
, so Jest cannot resolve it (https://github.com/sindresorhus/p-queue/blob/76b81cd707a6cd31b41f25e5d7fa8abc7486c4bf/package.json#L9)
exports
support is tracked in #9771
@SimenB Thank you for the clarification. It's unfortunate that even with ESM modules there are multiple flavors of packaging like this...
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.
🐛 Bug Report
I'm using the
is-what
module in my project. It was recently updated to be a pure ESM module as championed by Sindre (see https://blog.sindresorhus.com/get-ready-for-esm-aa53530b3f77), and after a tentative upgrade to that version, Jest can no longer resolve the module.The project itself is TypeScript, with
babel-jest
handling transpilation using (among others)@babel/preset-typescript
and (crucially for Jest, and only in the Jest babel env)@babel/plugin-transform-modules-commonjs
. (Let me know if you need full details.)Setting the
NODE_OPTIONS=--experimental-vm-modules
envvar as recommended elsewhere has no effect on this (other than spamming the console with warnings about how ESM support is experimental).The workaround is to explicitly tell Jest about the module's specifics, á la
but that's not workable in the long run, especially as more modules turn ESM.
This is not isolated to the
is-what
module; Sindre'sp-queue
(ESM since 7.x) has the same problem.To Reproduce
Attempt to import a pure-ESM module in a similarly configured repo. See https://github.com/akx/jest-esm-test (using
p-queue
as an example):Expected behavior
The module is resolved successfully, and in the best case automatically transpiled too in the absence of native ESM support in the Node runtime.
Link to repl or repo (highly encouraged)
https://github.com/akx/jest-esm-test
envinfo