Skip to content

Commit

Permalink
Include cache bundle version in hash
Browse files Browse the repository at this point in the history
This means that different versions automatically co-exist.
  • Loading branch information
Cykelero committed Jun 23, 2022
1 parent 62137d6 commit 4c6c571
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions source/PackageCache.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ const RuntimeVersion = require('./RuntimeVersion');
module.exports = {
PACKAGE_CACHE_PATH: path.join(Constants.CACHE_PATH, 'npm-packages', path.sep),
INDEX_FILE_NAME: 'index.js',
CACHE_BUNDLE_VERSION_COMMENT:
fs.readFileSync(
path.join(__dirname, 'packageCacheBundleIndexFile.template.js'),
{ encoding: 'utf8' }
)
.split('\n')[0],

_synchronouslyPreparedPackages: new Set(),

Expand Down Expand Up @@ -190,9 +196,13 @@ module.exports = {
},

_bundleHashForList(packageList) {
// The hash depends on included packages, their versions, and the cache bundle version
const sortedList = packageList.slice(0).sort();
const result = crypto.createHash('sha256').update(sortedList.join()).digest('hex');
return result;

return crypto.createHash('sha256')
.update(sortedList.join())
.update(this.CACHE_BUNDLE_VERSION_COMMENT)
.digest('hex');
},

_bundlePathForList(packageList) {
Expand Down

0 comments on commit 4c6c571

Please sign in to comment.