ModuleGraph/node-haste: remove dep over ResolutionRequest

Reviewed By: mjesun

Differential Revision: D7040976

fbshipit-source-id: 93d43342ee23b7f3496afbb532bbc12fefd6e61e
This commit is contained in:
Jean Lauliac 2018-02-23 10:18:11 -08:00 committed by Facebook Github Bot
parent 4670c08206
commit 0154fb32eb
1 changed files with 3 additions and 14 deletions

View File

@ -16,7 +16,6 @@ const FilesByDirNameIndex = require('../../node-haste/FilesByDirNameIndex');
const HasteFS = require('./HasteFS');
const Module = require('./Module');
const ModuleCache = require('./ModuleCache');
const ResolutionRequest = require('../../node-haste/DependencyGraph/ResolutionRequest');
const defaults = require('../../defaults');
const parsePlatformFilePath = require('../../node-haste/lib/parsePlatformFilePath');
@ -128,7 +127,6 @@ exports.createResolveFn = function(options: ResolveOptions): ResolveFn {
getTransformedFile,
);
const resolutionRequests = {};
const filesByDirNameIndex = new FilesByDirNameIndex(files);
const assetResolutionCache = new AssetResolutionCache({
assetExtensions: new Set(assetExts),
@ -153,21 +151,12 @@ exports.createResolveFn = function(options: ResolveOptions): ResolveFn {
});
return (id, sourcePath, platform, _, callback) => {
let resolutionRequest = resolutionRequests[platform];
if (!resolutionRequest) {
resolutionRequest = resolutionRequests[platform] = new ResolutionRequest({
moduleResolver,
entryPath: '',
helpers,
platform,
moduleCache,
});
}
const from =
sourcePath != null
? new Module(sourcePath, moduleCache, getTransformedFile(sourcePath))
: NULL_MODULE;
return resolutionRequest.resolveDependency(from, id).path;
const allowHaste = !helpers.isNodeModulesDir(from.path);
return moduleResolver.resolveDependency(from, id, allowHaste, platform)
.path;
};
};