fix: support deep CJS re-exports when using ESM - #13170
Conversation
|
|
||
| reexports.forEach(reexport => { | ||
| const resolved = this._resolveCjsModule(modulePath, reexport, { | ||
| conditions: this.esmConditions, |
There was a problem hiding this comment.
this specifically was the bug - we passed ESM conditions when figuring out CJS requires.
I moved all conditions into _resolveCjsModule and _resolveModule, that way this typo is way harder to make (and we always passed the same options anyways, no need for it to be an argument at all)
| { | ||
| "type": "module", | ||
| "devDependencies": { | ||
| "discord.js": "14.3.0" |
There was a problem hiding this comment.
I can't be bothered to recreate this case, just installing the module which reproduced is easier 😅
Essentially: ESM imports CJS, which re-exports (via CJS) modules which use exports to differentiate between ESM and CJS. Jest then picked out ESM when it should have picked out CJS
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
Fixes #12759
Test plan
Test added