Skip to content

Commit d620613

Browse files
robhoganfacebook-github-bot
authored andcommitted
Show base cache key hash with DEBUG=Metro:Transformer
Summary: Add a `debug` handy when debugging cache key mismatches / unexpected cache misses, especially in cases where stepping in with a debugger is tricky, and noting that print-based debugging is impossible because any change to this source changes the cache key. Changelog: Internal Reviewed By: yungsters Differential Revision: D74717070 fbshipit-source-id: 216ff7f15363aae8fd7ac6d31cdc18157abe3204
1 parent ca831c8 commit d620613

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

packages/metro/src/DeltaBundler/Transformer.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import crypto from 'crypto';
2020
const getTransformCacheKey = require('./getTransformCacheKey');
2121
const WorkerFarm = require('./WorkerFarm');
2222
const assert = require('assert');
23+
const debug = require('debug')('Metro:Transformer');
2324
const fs = require('fs');
2425
const {Cache, stableHash} = require('metro-cache');
2526
const path = require('path');
@@ -69,7 +70,9 @@ class Transformer {
6970
transformerConfig: transformerOptions,
7071
});
7172

72-
this._baseHash = stableHash([globalCacheKey]).toString('binary');
73+
const baseHashBuffer = stableHash([globalCacheKey]);
74+
this._baseHash = baseHashBuffer.toString('binary');
75+
debug('Base hash: %s', baseHashBuffer.toString('hex'));
7376
}
7477

7578
async transformFile(

0 commit comments

Comments
 (0)