Skip to content

Commit

Permalink
packager: remove unused imurmurhash
Browse files Browse the repository at this point in the history
Summary: This is not used by live code anymore.

Reviewed By: cpojer

Differential Revision: D5029114

fbshipit-source-id: 9ab9f6075407623debfe23bc121cc48ae8903917
  • Loading branch information
Jean Lauliac authored and facebook-github-bot committed May 10, 2017
1 parent c948ae8 commit cb3b744
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 12 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packager/src/JSTransformer/__tests__/Transformer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

jest
.unmock('stream')
.unmock('imurmurhash')
.unmock('crypto')
.unmock('../../lib/ModuleTransport')
.unmock('../');

Expand Down
11 changes: 6 additions & 5 deletions packager/src/lib/__mocks__/TransformCache.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

'use strict';

const imurmurhash = require('imurmurhash');
const crypto = require('crypto');
const jsonStableStringify = require('json-stable-stringify');

const transformCache = new Map();
Expand All @@ -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);
Expand Down
6 changes: 2 additions & 4 deletions packager/src/lib/__tests__/TransformCache-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -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}`},
},
};
Expand Down Expand Up @@ -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}`},
},
};
Expand Down
2 changes: 1 addition & 1 deletion packager/src/node-haste/__tests__/Module-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
jest
.dontMock('absolute-path')
.dontMock('json-stable-stringify')
.dontMock('imurmurhash')
.dontMock('crypto')
.dontMock('../lib/replacePatterns')
.dontMock('../DependencyGraph/docblock')
.dontMock('../Module');
Expand Down

0 comments on commit cb3b744

Please sign in to comment.