Move name resolution of inversed dependencies to HMR server

Summary:Name resolution of inversed dependencies used to happen in node-haste, but that makes it difficult switiching to numeric module IDs.
This moves the name resolution to the HMR server in order to be able to change the logic more easily.

node-haste 2.9.0 provides a `Map` of modules to `Set`s that contain the modules that depend on the key.

Reviewed By: martinbigio

Differential Revision: D3047414

fb-gh-sync-id: b98accea901d4da209dc4434ab111eb07ce9e2a0
shipit-source-id: b98accea901d4da209dc4434ab111eb07ce9e2a0
This commit is contained in:
David Aurelio 2016-03-14 08:55:19 -07:00 committed by Facebook Github Bot 8
parent 11202a77a3
commit 9d33905786
1 changed files with 18 additions and 10 deletions

View File

@ -81,16 +81,24 @@ function attachHMRServer({httpServer, path, packagerServer}) {
dependenciesModulesCache[depName] = dep;
});
})).then(() => {
return getInverseDependencies(response)
.then(inverseDependenciesCache => {
return {
dependenciesCache,
dependenciesModulesCache,
shallowDependencies,
inverseDependenciesCache,
resolutionResponse: response,
};
});
const inverseDependencies = getInverseDependencies(response);
const inverseDependenciesCache = Object.create(null);
return Promise.all(
Array.from(inverseDependencies).map(([module, dependents]) => {
return Promise.all([
module.getName(),
Promise.all(Array.from(dependents).map(m => m.getName())),
]).then(([moduleName, dependentsNames]) => {
inverseDependenciesCache[moduleName] = dependentsNames;
});
})
).then(() => ({
dependenciesCache,
dependenciesModulesCache,
shallowDependencies,
inverseDependenciesCache,
resolutionResponse: response,
}));
});
});
});