diff --git a/local-cli/server/util/attachHMRServer.js b/local-cli/server/util/attachHMRServer.js index 22323d071..362fdadf5 100644 --- a/local-cli/server/util/attachHMRServer.js +++ b/local-cli/server/util/attachHMRServer.js @@ -174,6 +174,16 @@ function attachHMRServer({httpServer, path, packagerServer}) { } }); + // Need to send modules to the client in an order it can + // process them: if a new dependency graph was uncovered + // because a new dependency was added, the file that was + // changed, which is the root of the dependency tree that + // will be sent, needs to be the last module that gets + // processed. Reversing the new modules makes sense + // because we get them through the resolver which returns + // a BFS ordered list. + modulesToUpdate.reverse(); + // invalidate caches client.dependenciesCache = dependenciesCache; client.dependenciesModulesCache = dependenciesModulesCache;