From cb3b744d084bbb3c44ee53b9da987b8b93c37c37 Mon Sep 17 00:00:00 2001 From: Jean Lauliac Date: Wed, 10 May 2017 03:44:54 -0700 Subject: [PATCH] packager: remove unused imurmurhash Summary: This is not used by live code anymore. Reviewed By: cpojer Differential Revision: D5029114 fbshipit-source-id: 9ab9f6075407623debfe23bc121cc48ae8903917 --- package.json | 1 - .../src/JSTransformer/__tests__/Transformer-test.js | 2 +- packager/src/lib/__mocks__/TransformCache.js | 11 ++++++----- packager/src/lib/__tests__/TransformCache-test.js | 6 ++---- packager/src/node-haste/__tests__/Module-test.js | 2 +- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 0d9f072ec..82fa6120f 100644 --- a/package.json +++ b/package.json @@ -169,7 +169,6 @@ "glob": "^7.1.1", "graceful-fs": "^4.1.3", "image-size": "^0.3.5", - "imurmurhash": "^0.1.4", "inquirer": "^0.12.0", "jest-haste-map": "19.0.0", "joi": "^6.6.1", diff --git a/packager/src/JSTransformer/__tests__/Transformer-test.js b/packager/src/JSTransformer/__tests__/Transformer-test.js index fc334f79a..ae9bcf32d 100644 --- a/packager/src/JSTransformer/__tests__/Transformer-test.js +++ b/packager/src/JSTransformer/__tests__/Transformer-test.js @@ -10,7 +10,7 @@ jest .unmock('stream') - .unmock('imurmurhash') + .unmock('crypto') .unmock('../../lib/ModuleTransport') .unmock('../'); diff --git a/packager/src/lib/__mocks__/TransformCache.js b/packager/src/lib/__mocks__/TransformCache.js index 1fd2261b7..f7cc9bb21 100644 --- a/packager/src/lib/__mocks__/TransformCache.js +++ b/packager/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/packager/src/lib/__tests__/TransformCache-test.js b/packager/src/lib/__tests__/TransformCache-test.js index af123ecb7..2230e9b0c 100644 --- a/packager/src/lib/__tests__/TransformCache-test.js +++ b/packager/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/packager/src/node-haste/__tests__/Module-test.js b/packager/src/node-haste/__tests__/Module-test.js index e4aca77e1..4500631a4 100644 --- a/packager/src/node-haste/__tests__/Module-test.js +++ b/packager/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');