Send HMR updates only for files on the bundle

Summary:
public

Compute the dependencies of the bundle entry file just before sending HMR updates. In case the file that was changed doesn't belong to the bundle bail.

Reviewed By: vjeux

Differential Revision: D2793736

fb-gh-sync-id: f858e71b0dd5fe4f5b2307a22c6cef627eb66a22
This commit is contained in:
Martín Bigio 2015-12-29 18:24:08 -08:00 committed by facebook-github-bot-8
parent d59f716a22
commit dcbc6708e3
4 changed files with 20 additions and 0 deletions

View File

@ -310,6 +310,10 @@ class Bundler {
this._transformer.invalidateFile(filePath);
}
getShallowDependencies(entryFile) {
return this._resolver.getShallowDependencies(entryFile);
}
getDependencies(main, isDev, platform) {
return this._resolver.getDependencies(main, { dev: isDev, platform });
}

View File

@ -133,6 +133,14 @@ class DependencyGraph {
return this._loading;
}
/**
* Returns a promise with the direct dependencies the module associated to
* the given entryPath has.
*/
getShallowDependencies(entryPath) {
return this._moduleCache.getModule(entryPath).getDependencies();
}
getDependencies(entryPath, platform) {
return this.load().then(() => {
platform = this._getRequestPlatform(entryPath, platform);

View File

@ -99,6 +99,10 @@ class Resolver {
this._polyfillModuleNames = opts.polyfillModuleNames || [];
}
getShallowDependencies(entryFile) {
return this._depGraph.getShallowDependencies(entryFile);
}
getDependencies(main, options) {
const opts = getDependenciesValidateOpts(options);

View File

@ -246,6 +246,10 @@ class Server {
});
}
getShallowDependencies(entryFile) {
return this._bundler.getShallowDependencies(entryFile);
}
getDependencies(options) {
return Promise.resolve().then(() => {
if (!options.platform) {