diff --git a/packages/metro-bundler/src/JSTransformer/__tests__/Transformer-test.js b/packages/metro-bundler/src/JSTransformer/__tests__/Transformer-test.js index fc334f79..ae9bcf32 100644 --- a/packages/metro-bundler/src/JSTransformer/__tests__/Transformer-test.js +++ b/packages/metro-bundler/src/JSTransformer/__tests__/Transformer-test.js @@ -10,7 +10,7 @@ jest .unmock('stream') - .unmock('imurmurhash') + .unmock('crypto') .unmock('../../lib/ModuleTransport') .unmock('../'); diff --git a/packages/metro-bundler/src/lib/__mocks__/TransformCache.js b/packages/metro-bundler/src/lib/__mocks__/TransformCache.js index 1fd2261b..f7cc9bb2 100644 --- a/packages/metro-bundler/src/lib/__mocks__/TransformCache.js +++ b/packages/metro-bundler/src/lib/__mocks__/TransformCache.js @@ -9,7 +9,7 @@ 'use strict'; -const imurmurhash = require('imurmurhash'); +const crypto = require('crypto'); const jsonStableStringify = require('json-stable-stringify'); const transformCache = new Map(); @@ -23,10 +23,11 @@ const mock = { }; const transformCacheKeyOf = props => - props.filePath + '-' + imurmurhash(props.sourceCode) - .hash(props.getTransformCacheKey(props.sourceCode, props.filePath, props.transformOptions)) - .hash(jsonStableStringify(props.transformOptions || {})) - .result().toString(16); + props.filePath + '-' + crypto.createHash('md5') + .update(props.sourceCode) + .update(props.getTransformCacheKey(props.sourceCode, props.filePath, props.transformOptions)) + .update(jsonStableStringify(props.transformOptions || {})) + .digest('hex'); function writeSync(props) { transformCache.set(transformCacheKeyOf(props), props.result); diff --git a/packages/metro-bundler/src/lib/__tests__/TransformCache-test.js b/packages/metro-bundler/src/lib/__tests__/TransformCache-test.js index af123ecb..2230e9b0 100644 --- a/packages/metro-bundler/src/lib/__tests__/TransformCache-test.js +++ b/packages/metro-bundler/src/lib/__tests__/TransformCache-test.js @@ -10,14 +10,12 @@ 'use strict'; jest - .dontMock('imurmurhash') .dontMock('json-stable-stringify') .dontMock('../TransformCache') .dontMock('left-pad') .dontMock('lodash/throttle') .dontMock('crypto'); -const imurmurhash = require('imurmurhash'); const crypto = require('crypto'); const jsonStableStringify = require('json-stable-stringify'); @@ -73,7 +71,7 @@ describe('TransformCache', () => { result: { code: `/* result for ${key} */`, dependencies: ['foo', `dep of ${key}`], - dependencyOffsets: [12, imurmurhash('dep' + key).result()], + dependencyOffsets: [12, 34], map: {desc: `source map for ${key}`}, }, }; @@ -108,7 +106,7 @@ describe('TransformCache', () => { result: { code: `/* result for ${key} */`, dependencies: ['foo', 'bar'], - dependencyOffsets: [12, imurmurhash('dep' + key).result()], + dependencyOffsets: [12, 34], map: {desc: `source map for ${key}`}, }, }; diff --git a/packages/metro-bundler/src/node-haste/__tests__/Module-test.js b/packages/metro-bundler/src/node-haste/__tests__/Module-test.js index e4aca77e..4500631a 100644 --- a/packages/metro-bundler/src/node-haste/__tests__/Module-test.js +++ b/packages/metro-bundler/src/node-haste/__tests__/Module-test.js @@ -11,7 +11,7 @@ jest .dontMock('absolute-path') .dontMock('json-stable-stringify') - .dontMock('imurmurhash') + .dontMock('crypto') .dontMock('../lib/replacePatterns') .dontMock('../DependencyGraph/docblock') .dontMock('../Module');