mirror of https://github.com/status-im/metro.git
Introduce transformer `cacheKey`
Summary:public At the moment, the packager's cache can only be broken by changing packager's `package.json` version,by supplying a different `cacheKey` or by updating the `mtime` of the transformer. We need to add support for breaking the cache key when a plugin the transformer use gets updated. To do so, lets introduce a property on the transformer, namely `cacheKey`. Reviewed By: davidaurelio Differential Revision: D2940267 fb-gh-sync-id: 82c937d06c73abd32708bf97afe5f308c2a3b565 shipit-source-id: 82c937d06c73abd32708bf97afe5f308c2a3b565
This commit is contained in:
parent
109532086f
commit
ccbf9273fe
|
@ -103,15 +103,24 @@ class Bundler {
|
|||
mtime = '';
|
||||
}
|
||||
|
||||
const cacheKeyParts = [
|
||||
'react-packager-cache',
|
||||
version,
|
||||
opts.cacheVersion,
|
||||
opts.projectRoots.join(',').split(path.sep).join('-'),
|
||||
mtime,
|
||||
];
|
||||
|
||||
if (opts.transformModulePath) {
|
||||
const transformer = require(opts.transformModulePath);
|
||||
if (typeof transformer.cacheKey !== 'undefined') {
|
||||
cacheKeyParts.push(transformer.cacheKey);
|
||||
}
|
||||
}
|
||||
|
||||
this._cache = new Cache({
|
||||
resetCache: opts.resetCache,
|
||||
cacheKey: [
|
||||
'react-packager-cache',
|
||||
version,
|
||||
opts.cacheVersion,
|
||||
opts.projectRoots.join(',').split(path.sep).join('-'),
|
||||
mtime
|
||||
].join('$'),
|
||||
cacheKey: cacheKeyParts.join('$'),
|
||||
});
|
||||
|
||||
this._resolver = new Resolver({
|
||||
|
|
Loading…
Reference in New Issue