packager: Bundler: use transform module hash instead of mtime
Summary: mtime is a problem for the global cache, because everyone has different times at which they rebased/cloned the repo. Use the actual content instead. Of course, the file could depend on other files we don't take into account... but the mtime solution was already problematic in that regard, so I assume this is a safe change. Reviewed By: davidaurelio Differential Revision: D4237826 fbshipit-source-id: 9dc18eb422cddd4d5ed097d1ebeef4b8c361ff39
This commit is contained in:
parent
a50bafa678
commit
e485f6997d
|
@ -12,6 +12,7 @@
|
|||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const crypto = require('crypto');
|
||||
const fs = require('fs');
|
||||
const Cache = require('../node-haste').Cache;
|
||||
const Transformer = require('../JSTransformer');
|
||||
|
@ -146,12 +147,13 @@ class Bundler {
|
|||
|
||||
opts.projectRoots.forEach(verifyRootExists);
|
||||
|
||||
let mtime;
|
||||
let transformModuleHash;
|
||||
try {
|
||||
({mtime} = fs.statSync(opts.transformModulePath));
|
||||
mtime = String(mtime.getTime());
|
||||
const transformModuleStr = fs.readFileSync(opts.transformModulePath);
|
||||
transformModuleHash =
|
||||
crypto.createHash('sha1').update(transformModuleStr).digest('hex');
|
||||
} catch (error) {
|
||||
mtime = '';
|
||||
transformModuleHash = '';
|
||||
}
|
||||
|
||||
const cacheKeyParts = [
|
||||
|
@ -159,7 +161,7 @@ class Bundler {
|
|||
version,
|
||||
opts.cacheVersion,
|
||||
opts.projectRoots.join(',').split(pathSeparator).join('-'),
|
||||
mtime,
|
||||
transformModuleHash,
|
||||
];
|
||||
|
||||
this._getModuleId = createModuleIdFactory();
|
||||
|
|
Loading…
Reference in New Issue