diff --git a/CHANGELOG.md b/CHANGELOG.md index 80c462425b36..e22bb5132407 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -81,6 +81,7 @@ - `[@jest/expect-utils]` Check `Symbol` properties in equality ([#14688](https://github.com/jestjs/jest/pull/14688)) - `[@jest/expect-utils]` Catch circular references within arrays when matching objects ([#14894](https://github.com/jestjs/jest/pull/14894)) - `[@jest/expect-utils]` Fix not addressing to Sets and Maps as objects without keys ([#14873](https://github.com/jestjs/jest/pull/14873)) +- `[jest-haste-map]` Fix errors or clobbering with multiple `hasteImplModulePath`s ([#15522](https://github.com/jestjs/jest/pull/15522)) - `[jest-leak-detector]` Make leak-detector more aggressive when running GC ([#14526](https://github.com/jestjs/jest/pull/14526)) - `[jest-runtime]` Properly handle re-exported native modules in ESM via CJS ([#14589](https://github.com/jestjs/jest/pull/14589)) - `[jest-schemas, jest-types]` [**BREAKING**] Fix type of `testFailureExitCode` config option([#15232](https://github.com/jestjs/jest/pull/15232)) diff --git a/packages/jest-haste-map/src/worker.ts b/packages/jest-haste-map/src/worker.ts index 699480a05929..4eec06ad8dd0 100644 --- a/packages/jest-haste-map/src/worker.ts +++ b/packages/jest-haste-map/src/worker.ts @@ -21,24 +21,14 @@ import type { const PACKAGE_JSON = `${path.sep}package.json`; -let hasteImpl: HasteImpl | null = null; -let hasteImplModulePath: string | null = null; - function sha1hex(content: string | Buffer): string { return createHash('sha1').update(content).digest('hex'); } export async function worker(data: WorkerMessage): Promise { - if ( - data.hasteImplModulePath && - data.hasteImplModulePath !== hasteImplModulePath - ) { - if (hasteImpl) { - throw new Error('jest-haste-map: hasteImplModulePath changed'); - } - hasteImplModulePath = data.hasteImplModulePath; - hasteImpl = require(hasteImplModulePath); - } + const hasteImpl: HasteImpl | null = data.hasteImplModulePath + ? require(data.hasteImplModulePath) + : null; let content: string | undefined; let dependencies: WorkerMetadata['dependencies'];