Use SHA-1 on experimental caches

Reviewed By: jeanlauliac

Differential Revision: D7399785

fbshipit-source-id: c8e842390e27d7954ca78dcd5c4b7e2a115d1b9d
This commit is contained in:
Miguel Jimenez Esun 2018-04-09 15:31:05 -07:00 committed by Facebook Github Bot
parent caf4fe379f
commit 9045aad7e4
2 changed files with 14 additions and 2 deletions

View File

@ -291,9 +291,9 @@ class Bundler {
// This is the hash related to the global Bundler config.
this._baseHash,
// Path and code.
// Path and code hash.
module.localPath,
code,
(await this.getDependencyGraph()).getSha1(module.path),
// We cannot include "transformCodeOptions" because of "projectRoot".
assetDataPlugins,

View File

@ -109,6 +109,7 @@ class DependencyGraph extends EventEmitter {
useWatchman?: boolean = true,
): JestHasteMap {
return new JestHasteMap({
computeSha1: true,
extensions: opts.sourceExts.concat(opts.assetExts),
forceNodeFilesystemAPI: !useWatchman,
hasteImplModulePath: opts.hasteImplModulePath,
@ -234,6 +235,17 @@ class DependencyGraph extends EventEmitter {
return result.dependencies;
}
getSha1(filename: string): string {
// $FlowFixMe: TODO T27501330: Use getSha1 from HasteFS.
const sha1 = this._hasteFS._files[filename][4];
if (!sha1) {
throw new ReferenceError(`SHA-1 for file ${filename} is not computed`);
}
return sha1;
}
getWatcher() {
return this._haste;
}