HMR nits detected by the linter
Reviewed By: davidaurelio Differential Revision: D3042850 fb-gh-sync-id: 03fd239b0dea2d7d4ef778e2d07d41af84fe310d shipit-source-id: 03fd239b0dea2d7d4ef778e2d07d41af84fe310d
This commit is contained in:
parent
83095f95b5
commit
780a513b7b
|
@ -62,12 +62,16 @@ function attachHMRServer({httpServer, path, packagerServer}) {
|
|||
|
||||
// map from module name to path
|
||||
const moduleToFilenameCache = Object.create(null);
|
||||
deps.forEach(dep => moduleToFilenameCache[dep.name] = dep.path);
|
||||
deps.forEach(dep => {
|
||||
moduleToFilenameCache[dep.name] = dep.path;
|
||||
});
|
||||
|
||||
// map that indicates the shallow dependency each file included on the
|
||||
// bundle has
|
||||
const shallowDependencies = Object.create(null);
|
||||
deps.forEach(dep => shallowDependencies[dep.path] = dep.deps);
|
||||
deps.forEach(dep => {
|
||||
shallowDependencies[dep.path] = dep.deps;
|
||||
});
|
||||
|
||||
// map from module name to the modules' dependencies the bundle entry
|
||||
// has
|
||||
|
@ -128,8 +132,8 @@ function attachHMRServer({httpServer, path, packagerServer}) {
|
|||
`[Hot Module Replacement] File change detected (${time()})`
|
||||
);
|
||||
|
||||
const blacklisted = blacklist.find(path =>
|
||||
filename.indexOf(path) !== -1
|
||||
const blacklisted = blacklist.find(blacklistedPath =>
|
||||
filename.indexOf(blacklistedPath) !== -1
|
||||
);
|
||||
|
||||
if (blacklisted) {
|
||||
|
@ -170,10 +174,10 @@ function attachHMRServer({httpServer, path, packagerServer}) {
|
|||
// dependencies we used to have with the one we now have
|
||||
return getDependencies(client.platform, client.bundleEntry)
|
||||
.then(({
|
||||
dependenciesCache,
|
||||
dependenciesModulesCache,
|
||||
shallowDependencies,
|
||||
inverseDependenciesCache,
|
||||
depsCache,
|
||||
depsModulesCache,
|
||||
shallowDeps,
|
||||
inverseDepsCache,
|
||||
resolutionResponse,
|
||||
}) => {
|
||||
if (!client) {
|
||||
|
@ -182,9 +186,9 @@ function attachHMRServer({httpServer, path, packagerServer}) {
|
|||
|
||||
// build list of modules for which we'll send HMR updates
|
||||
const modulesToUpdate = [packagerServer.getModuleForPath(filename)];
|
||||
Object.keys(dependenciesModulesCache).forEach(module => {
|
||||
if (!client.dependenciesModulesCache[module]) {
|
||||
modulesToUpdate.push(dependenciesModulesCache[module]);
|
||||
Object.keys(depsModulesCache).forEach(module => {
|
||||
if (!client.depsModulesCache[module]) {
|
||||
modulesToUpdate.push(depsModulesCache[module]);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -199,9 +203,10 @@ function attachHMRServer({httpServer, path, packagerServer}) {
|
|||
modulesToUpdate.reverse();
|
||||
|
||||
// invalidate caches
|
||||
client.dependenciesCache = dependenciesCache;
|
||||
client.dependenciesModulesCache = dependenciesModulesCache;
|
||||
client.shallowDependencies = shallowDependencies;
|
||||
client.dependenciesCache = depsCache;
|
||||
client.dependenciesModulesCache = depsModulesCache;
|
||||
client.shallowDependencies = shallowDeps;
|
||||
client.inverseDependenciesCache = inverseDepsCache;
|
||||
|
||||
return resolutionResponse.copy({
|
||||
dependencies: modulesToUpdate
|
||||
|
@ -228,13 +233,11 @@ function attachHMRServer({httpServer, path, packagerServer}) {
|
|||
packagerHost = httpServerAddress.address;
|
||||
}
|
||||
|
||||
let packagerPort = httpServerAddress.port;
|
||||
|
||||
return packagerServer.buildBundleForHMR({
|
||||
entryFile: client.bundleEntry,
|
||||
platform: client.platform,
|
||||
resolutionResponse,
|
||||
}, packagerHost, packagerPort);
|
||||
}, packagerHost, httpServerAddress.port);
|
||||
})
|
||||
.then(bundle => {
|
||||
if (!client || !bundle || bundle.isEmpty()) {
|
||||
|
@ -245,7 +248,7 @@ function attachHMRServer({httpServer, path, packagerServer}) {
|
|||
type: 'update',
|
||||
body: {
|
||||
modules: bundle.getModulesNamesAndCode(),
|
||||
inverseDependencies: inverseDependenciesCache,
|
||||
inverseDependencies: client.inverseDependenciesCache,
|
||||
sourceURLs: bundle.getSourceURLs(),
|
||||
sourceMappingURLs: bundle.getSourceMappingURLs(),
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue