Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
### Performance

- `[*]` [**BREAKING**] Bundle all of Jest's modules into `index.js` ([#12348](https://github.com/jestjs/jest/pull/12348), [#14550](https://github.com/jestjs/jest/pull/14550) & [#14661](https://github.com/jestjs/jest/pull/14661))
- `[*]` [jest-haste-map] Only spawn one process to check for `watchman` installation ([#14826](https://github.com/jestjs/jest/pull/14826))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hah, totally wrong format 😅

should be

 `[jest-haste-map]` Only spawn one process to check for `watchman` installation ([#14826](https://github.com/jestjs/jest/pull/14826))


### Chore & Maintenance

Expand Down
12 changes: 3 additions & 9 deletions packages/jest-core/src/getChangedFilesPromise.ts
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this has nothing to do with the other fix, just sneaking it in as #14804 missed it

Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,10 @@ export default function getChangedFilesPromise(
configs: Array<Config.ProjectConfig>,
): ChangedFilesPromise | undefined {
if (globalConfig.onlyChanged) {
const allRootsForAllProjects = configs.reduce<Array<string>>(
(roots, config) => {
if (config.roots) {
roots.push(...config.roots);
}
return roots;
},
[],
const allRootsForAllProjects = new Set(
configs.flatMap(config => config.roots || []),
);
return getChangedFilesForRoots(allRootsForAllProjects, {
return getChangedFilesForRoots([...allRootsForAllProjects], {
changedSince: globalConfig.changedSince,
lastCommit: globalConfig.lastCommit,
withAncestor: globalConfig.changedFilesWithAncestor,
Expand Down
9 changes: 5 additions & 4 deletions packages/jest-haste-map/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ type Watcher = {

type HasteWorker = typeof import('./worker');

let isWatchmanInstalledPromise: Promise<boolean> | undefined;

export const ModuleMap = HasteModuleMap as {
create: (rootPath: string) => IModuleMap;
};
Expand Down Expand Up @@ -216,7 +218,6 @@ class HasteMap extends EventEmitter implements IHasteMap {
private _cachePath = '';
private _changeInterval?: ReturnType<typeof setInterval>;
private readonly _console: Console;
private _isWatchmanInstalledPromise: Promise<boolean> | null = null;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this made the check happens once per project, while we now do it once per module scope (i.e. once per worker/thread/process)

private readonly _options: InternalOptions;
private _watchers: Array<Watcher> = [];
private _worker: JestWorkerFarm<HasteWorker> | HasteWorker | null = null;
Expand Down Expand Up @@ -1108,10 +1109,10 @@ class HasteMap extends EventEmitter implements IHasteMap {
if (!this._options.useWatchman) {
return false;
}
if (!this._isWatchmanInstalledPromise) {
this._isWatchmanInstalledPromise = isWatchmanInstalled();
if (!isWatchmanInstalledPromise) {
isWatchmanInstalledPromise = isWatchmanInstalled();
}
return this._isWatchmanInstalledPromise;
return isWatchmanInstalledPromise;
}

private _createEmptyMap(): InternalHasteMap {
Expand Down