-
Notifications
You must be signed in to change notification settings - Fork 662
Description
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
I am using a custom resolver.resolveRequest
function in rn-cli.config.js
. See https://facebook.github.io/metro/docs/en/configuration#resolver-options.
The error message is being printed from metro/src/node-haste/DependencyGraph.js#getSha1
, which is being called by metro/src/Bundler.js#transformFile
:
metro/src/node-haste/DependencyGraph.js#getSha1
getSha1(filename: string): string {
const resolvedPath = fs.realpathSync(filename);
const sha1 = this._hasteFS.getSha1(resolvedPath);
if (!sha1) {
throw new ReferenceError(`SHA-1 for file ${filename} is not computed`);
}
return sha1;
}
The issue is that the file won't exist in the haste map if you are resolving it in the resolveRequest
hook.
If the current behavior is a bug, please provide the steps to reproduce and a minimal repository on GitHub that we can yarn install
and yarn test
.
https://github.com/vjpr/expo-v2-test-pnpm/tree/broken
You need to run pnpm install
(the reason for the custom resolver is because symlinks are not supported by metro and hence cause problems for pnpm).
What is the expected behavior?
getSha1
should compute hash if not in haste map.
Please provide your exact Metro configuration and mention your Metro, node, yarn/npm version and operating system.
[email protected]
[email protected]
[email protected]
Workaround
Add to metro/src/node-haste/DependencyGraph.js#getSha1:
if (!sha1) {
return getFileHash(resolvedPath)
function getFileHash(file) {
return require('crypto')
.createHash('sha1')
.update(fs.readFileSync(file))
.digest('hex')
}
}
I have released a patched version here: Use [email protected]