Skip to content

Commit 54673fd

Browse files
authored
fix(jest-haste-map): Fix clobbering/errors when multiple configs use different haste impls (#15522)
1 parent 46964d4 commit 54673fd

File tree

2 files changed

+4
-13
lines changed

2 files changed

+4
-13
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
- `[@jest/expect-utils]` Check `Symbol` properties in equality ([#14688](https://github.com/jestjs/jest/pull/14688))
8383
- `[@jest/expect-utils]` Catch circular references within arrays when matching objects ([#14894](https://github.com/jestjs/jest/pull/14894))
8484
- `[@jest/expect-utils]` Fix not addressing to Sets and Maps as objects without keys ([#14873](https://github.com/jestjs/jest/pull/14873))
85+
- `[jest-haste-map]` Fix errors or clobbering with multiple `hasteImplModulePath`s ([#15522](https://github.com/jestjs/jest/pull/15522))
8586
- `[jest-leak-detector]` Make leak-detector more aggressive when running GC ([#14526](https://github.com/jestjs/jest/pull/14526))
8687
- `[jest-runtime]` Properly handle re-exported native modules in ESM via CJS ([#14589](https://github.com/jestjs/jest/pull/14589))
8788
- `[jest-runtime]` Refactor `_importCoreModel` so required core module is consistent if modified while loading ([#15077](https://github.com/jestjs/jest/issues/15077))

packages/jest-haste-map/src/worker.ts

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,14 @@ import type {
2121

2222
const PACKAGE_JSON = `${path.sep}package.json`;
2323

24-
let hasteImpl: HasteImpl | null = null;
25-
let hasteImplModulePath: string | null = null;
26-
2724
function sha1hex(content: string | Buffer): string {
2825
return createHash('sha1').update(content).digest('hex');
2926
}
3027

3128
export async function worker(data: WorkerMessage): Promise<WorkerMetadata> {
32-
if (
33-
data.hasteImplModulePath &&
34-
data.hasteImplModulePath !== hasteImplModulePath
35-
) {
36-
if (hasteImpl) {
37-
throw new Error('jest-haste-map: hasteImplModulePath changed');
38-
}
39-
hasteImplModulePath = data.hasteImplModulePath;
40-
hasteImpl = require(hasteImplModulePath);
41-
}
29+
const hasteImpl: HasteImpl | null = data.hasteImplModulePath
30+
? require(data.hasteImplModulePath)
31+
: null;
4232

4333
let content: string | undefined;
4434
let dependencies: WorkerMetadata['dependencies'];

0 commit comments

Comments
 (0)