Make a common hash of all the bundler information

Reviewed By: davidaurelio

Differential Revision: D7196792

fbshipit-source-id: dc1e0b399d1d5ff9c0956facd69be4279cc4f5c3
This commit is contained in:
Miguel Jimenez Esun 2018-03-12 03:51:34 -07:00 committed by Facebook Github Bot
parent b8d20a089c
commit 601f718dd6
1 changed files with 15 additions and 3 deletions

View File

@ -112,6 +112,7 @@ const {hasOwnProperty} = Object.prototype;
class Bundler {
_opts: Options;
_cache: ?Cache<TransformedCode>;
_baseHash: string;
_transformer: Transformer;
_depGraphPromise: Promise<DependencyGraph>;
_projectRoots: $ReadOnlyArray<string>;
@ -169,6 +170,16 @@ class Bundler {
watch: opts.watch,
});
this._baseHash = stableHash([
opts.assetExts,
opts.assetRegistryPath,
opts.asyncRequireModulePath,
opts.cacheVersion,
opts.dynamicDepsInPackages,
opts.projectRoots,
opts.transformModulePath,
]).toString('binary');
this._projectRoots = opts.projectRoots;
this._getTransformOptions = opts.getTransformOptions;
}
@ -278,11 +289,12 @@ class Bundler {
}
key = stableHash([
// This is the hash related to the global Bundler config.
this._baseHash,
// Path and code.
module.localPath,
code,
this._opts.assetExts,
this._opts.assetRegistryPath,
this._opts.cacheVersion,
// We cannot include "transformCodeOptions" because of "projectRoot".
assetDataPlugins,