Skip to content

Commit 05dd38b

Browse files
committed
[jest-haste-map] Remove mapper option.
1 parent 63593a2 commit 05dd38b

File tree

6 files changed

+3
-76
lines changed

6 files changed

+3
-76
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
- `[jest-config]` Support ESM config files with `.js` extension ([#9573](https://github.com/facebook/jest/9573)).
66
- `[jest-runtime]` Override `module.createRequire` to return a Jest-compatible `require` function ([#9469](https://github.com/facebook/jest/pull/9469))
7+
- `[jest-haste-map]` [**BREAKING**] Remove `mapper` option ([#9581](https://github.com/facebook/jest/pull/9581))
78
- `[*]` Support array of paths for `moduleNameMapper` aliases ([#9465](https://github.com/facebook/jest/pull/9465))
89
- `[jest-reporters]` Adds ability to pass options to the istanbul-reporter through `coverageReporters` ([#9572](https://github.com/facebook/jest/pull/9572))
910

packages/jest-haste-map/src/__tests__/index.test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,6 @@ describe('HasteMap', () => {
426426
const hasteMap = new HasteMap({
427427
...defaultConfig,
428428
computeSha1: true,
429-
mapper: file => [file],
430429
maxWorkers: 1,
431430
useWatchman,
432431
});

packages/jest-haste-map/src/crawlers/__tests__/watchman.test.js

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ const STRAWBERRY_RELATIVE = path.join(FRUITS_RELATIVE, 'strawberry.js');
4444
const KIWI_RELATIVE = path.join(FRUITS_RELATIVE, 'kiwi.js');
4545
const TOMATO_RELATIVE = path.join(FRUITS_RELATIVE, 'tomato.js');
4646
const MELON_RELATIVE = path.join(VEGETABLES_RELATIVE, 'melon.json');
47-
const DURIAN_RELATIVE = path.join(VEGETABLES_RELATIVE, 'durian.zip');
4847

4948
const WATCH_PROJECT_MOCK = {
5049
[FRUITS]: {
@@ -174,56 +173,6 @@ describe('watchman watch', () => {
174173
expect(client.end).toBeCalled();
175174
}));
176175

177-
test('applies the mapper when needed', () => {
178-
mockResponse = {
179-
'list-capabilities': {
180-
[undefined]: {
181-
capabilities: ['field-content.sha1hex'],
182-
},
183-
},
184-
query: {
185-
[ROOT_MOCK]: {
186-
clock: 'c:fake-clock:1',
187-
files: [
188-
{
189-
exists: true,
190-
mtime_ms: {toNumber: () => 33},
191-
name: 'vegetables/durian.zip',
192-
size: 43,
193-
},
194-
],
195-
is_fresh_instance: true,
196-
version: '4.5.0',
197-
},
198-
},
199-
'watch-project': WATCH_PROJECT_MOCK,
200-
};
201-
202-
return watchmanCrawl({
203-
data: {
204-
clocks: new Map(),
205-
files: new Map(),
206-
},
207-
extensions: ['js', 'json', 'zip'],
208-
ignore: pearMatcher,
209-
mapper: n =>
210-
n.endsWith('.zip')
211-
? [path.join(n, 'foo.1.js'), path.join(n, 'foo.2.js')]
212-
: null,
213-
rootDir: ROOT_MOCK,
214-
roots: ROOTS,
215-
}).then(({changedFiles, hasteMap, removedFiles}) => {
216-
expect(changedFiles).toEqual(undefined);
217-
expect(hasteMap.files).toEqual(
218-
createMap({
219-
[path.join(DURIAN_RELATIVE, 'foo.1.js')]: ['', 33, 43, 0, '', null],
220-
[path.join(DURIAN_RELATIVE, 'foo.2.js')]: ['', 33, 43, 0, '', null],
221-
}),
222-
);
223-
expect(removedFiles).toEqual(new Map());
224-
});
225-
});
226-
227176
test('updates file map and removedFiles when the clock is given', () => {
228177
mockResponse = {
229178
'list-capabilities': {

packages/jest-haste-map/src/crawlers/watchman.ts

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -235,23 +235,8 @@ export = async function watchmanCrawl(
235235
nextData = ['', mtime, size, 0, '', sha1hex];
236236
}
237237

238-
const mappings = options.mapper ? options.mapper(filePath) : null;
239-
240-
if (mappings) {
241-
for (const absoluteVirtualFilePath of mappings) {
242-
if (!ignore(absoluteVirtualFilePath)) {
243-
const relativeVirtualFilePath = fastPath.relative(
244-
rootDir,
245-
absoluteVirtualFilePath,
246-
);
247-
files.set(relativeVirtualFilePath, nextData);
248-
changedFiles.set(relativeVirtualFilePath, nextData);
249-
}
250-
}
251-
} else {
252-
files.set(relativeFilePath, nextData);
253-
changedFiles.set(relativeFilePath, nextData);
254-
}
238+
files.set(relativeFilePath, nextData);
239+
changedFiles.set(relativeFilePath, nextData);
255240
}
256241
}
257242
}

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ import {
3939
HasteRegExp,
4040
InternalHasteMap,
4141
HasteMap as InternalHasteMapObject,
42-
Mapper,
4342
MockData,
4443
ModuleMapData,
4544
ModuleMetaData,
@@ -58,7 +57,6 @@ type Options = {
5857
forceNodeFilesystemAPI?: boolean;
5958
hasteImplModulePath?: string;
6059
ignorePattern?: HasteRegExp;
61-
mapper?: Mapper;
6260
maxWorkers: number;
6361
mocksPattern?: string;
6462
name: string;
@@ -83,7 +81,6 @@ type InternalOptions = {
8381
forceNodeFilesystemAPI: boolean;
8482
hasteImplModulePath?: string;
8583
ignorePattern?: HasteRegExp;
86-
mapper?: Mapper;
8784
maxWorkers: number;
8885
mocksPattern: RegExp | null;
8986
name: string;
@@ -261,7 +258,6 @@ class HasteMap extends EventEmitter {
261258
forceNodeFilesystemAPI: !!options.forceNodeFilesystemAPI,
262259
hasteImplModulePath: options.hasteImplModulePath,
263260
ignorePattern: options.ignorePattern,
264-
mapper: options.mapper,
265261
maxWorkers: options.maxWorkers,
266262
mocksPattern: options.mocksPattern
267263
? new RegExp(options.mocksPattern)
@@ -755,7 +751,6 @@ class HasteMap extends EventEmitter {
755751
extensions: options.extensions,
756752
forceNodeFilesystemAPI: options.forceNodeFilesystemAPI,
757753
ignore,
758-
mapper: options.mapper,
759754
rootDir: options.rootDir,
760755
roots: options.roots,
761756
};

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import ModuleMap from './ModuleMap';
1111
import HasteFS from './HasteFS';
1212

1313
export type IgnoreMatcher = (item: string) => boolean;
14-
export type Mapper = (item: string) => Array<string> | null;
1514

1615
export type WorkerMessage = {
1716
computeDependencies: boolean;
@@ -35,7 +34,6 @@ export type CrawlerOptions = {
3534
extensions: Array<string>;
3635
forceNodeFilesystemAPI: boolean;
3736
ignore: IgnoreMatcher;
38-
mapper?: Mapper | null;
3937
rootDir: string;
4038
roots: Array<string>;
4139
};

0 commit comments

Comments
 (0)