You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In packages/jest-resolve/src/defaultResolver.ts, jest search only for "main" field to resolve package without checking if a "exports" field defines which file to read. This is different than what Node.js does to resolve package. This cause problems when a module is "type:module" and has a "exports->require" to be able to use it in a CommonJS file.
Here is the relevant part of packages/jest-resolve/src/defaultResolver.ts
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.
Version
27.5.1
Steps to reproduce
In packages/jest-resolve/src/defaultResolver.ts, jest search only for "main" field to resolve package without checking if a "exports" field defines which file to read. This is different than what Node.js does to resolve package. This cause problems when a module is "type:module" and has a "exports->require" to be able to use it in a CommonJS file.
Here is the relevant part of
packages/jest-resolve/src/defaultResolver.ts
Expected behavior
Follow Node.js behavior
Actual behavior
Module foo is a commonjs module. It uses
require('bar')
. Module bar is a ES module:Jest reads
bar/index.js
instead ofbar/index.cjs
Additional context
No response
Environment
The text was updated successfully, but these errors were encountered: