Skip to content

Commit

Permalink
Introduce transformer cacheKey
Browse files Browse the repository at this point in the history
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
  • Loading branch information
martinbigio authored and facebook-github-bot-4 committed Feb 17, 2016
1 parent f2b95f2 commit b5f8006
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions packager/react-packager/src/Bundler/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

0 comments on commit b5f8006

Please sign in to comment.