Skip to content

Commit

Permalink
Fix candidate for a problem when core module is reexported from cjs
Browse files Browse the repository at this point in the history
  • Loading branch information
kowalski committed Feb 3, 2023
1 parent 48ddbf4 commit fb756c1
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions packages/jest-runtime/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -951,11 +951,18 @@ export default class Runtime {
const namedExports = new Set(exports);

reexports.forEach(reexport => {
const resolved = this._resolveCjsModule(modulePath, reexport);
if (this._resolver.isCoreModule(reexport)) {
const exports = this.requireModule(modulePath, reexport);
if (exports !== null && typeof exports === 'object') {
Object.keys(exports).forEach(namedExports.add, namedExports);
}
} else {
const resolved = this._resolveCjsModule(modulePath, reexport);

const exports = this.getExportsOfCjs(resolved);
const exports = this.getExportsOfCjs(resolved);

exports.forEach(namedExports.add, namedExports);
exports.forEach(namedExports.add, namedExports);
}
});

this._cjsNamedExports.set(modulePath, namedExports);
Expand Down

0 comments on commit fb756c1

Please sign in to comment.