Skip to content

Commit

Permalink
Revert "Improve data structure for deprecated files"
Browse files Browse the repository at this point in the history
This reverts commit aed9fd9.
  • Loading branch information
rubennorte committed Nov 6, 2018
1 parent c09e3f9 commit f5321bf
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions packages/jest-haste-map/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import type {Mapper} from './types';
import type {Path} from 'types/Config';
import type {
HasteMap as HasteMapObject,
FileData as HasteMapFileData,
InternalHasteMap,
ModuleMetaData,
ModuleMapData,
Expand Down Expand Up @@ -361,7 +360,7 @@ class HasteMap extends EventEmitter {
* 2. crawl the file system.
*/
_buildFileMap(): Promise<{
deprecatedFiles: HasteMapFileData,
deprecatedFiles: Array<{moduleName: string, path: string}>,
hasteMap: InternalHasteMap,
}> {
const read = this._options.resetCache ? this._createEmptyMap : this.read;
Expand All @@ -372,10 +371,10 @@ class HasteMap extends EventEmitter {
.then(cachedHasteMap => {
const cachedFiles = new Map(cachedHasteMap.files);
return this._crawl(cachedHasteMap).then(hasteMap => {
const deprecatedFiles = new Map();
const deprecatedFiles = [];
for (const [fileName, fileData] of cachedFiles) {
if (!hasteMap.files.has(fileName)) {
deprecatedFiles.set(fileName, fileData);
deprecatedFiles.push({path: fileName, moduleName: fileData[H.ID]});
}
}
return {deprecatedFiles, hasteMap};
Expand Down Expand Up @@ -579,17 +578,17 @@ class HasteMap extends EventEmitter {
}

_buildHasteMap(data: {
deprecatedFiles: HasteMapFileData,
deprecatedFiles: Array<{moduleName: string, path: string}>,
hasteMap: InternalHasteMap,
}): Promise<InternalHasteMap> {
const {deprecatedFiles, hasteMap} = data;
const map = new Map();
const mocks = new Map();
const promises = [];

for (const [filePath, fileData] of deprecatedFiles) {
const moduleName = fileData[H.ID];
this._recoverDuplicates(hasteMap, filePath, moduleName);
for (let i = 0; i < deprecatedFiles.length; ++i) {
const file = deprecatedFiles[i];
this._recoverDuplicates(hasteMap, file.path, file.moduleName);
}

for (const relativeFilePath of hasteMap.files.keys()) {
Expand Down

0 comments on commit f5321bf

Please sign in to comment.