mirror of https://github.com/status-im/metro.git
metro-buck: getLibrary: precompute asset hashes
Reviewed By: davidaurelio Differential Revision: D6937279 fbshipit-source-id: 328f06b2b66eeed6fd2f767dab1a03854c4dd28c
This commit is contained in:
parent
01a92f3c2f
commit
1498c4ba6b
|
@ -196,6 +196,10 @@ export type AssetFile = {|
|
|||
* Guessed from the file extension, for example `png` or `html`.
|
||||
*/
|
||||
+contentType: string,
|
||||
/**
|
||||
* Hash of the asset file content.
|
||||
*/
|
||||
+hash: string,
|
||||
/**
|
||||
* The path of the original file for this asset. For example
|
||||
* `foo/bar@3x.ios.png`. This is most useful for reporting purposes, such as
|
||||
|
|
|
@ -7,6 +7,7 @@ Object {
|
|||
"contentBase64": "eyJfX3NpemUiOnsid2lkdGgiOjMwLCJoZWlnaHQiOjIwfX0=",
|
||||
"contentType": "png",
|
||||
"filePath": "foo.png",
|
||||
"hash": "AGicIEH/IsIy5t7si/9ocI6Ur8s=",
|
||||
"physicalSize": Object {
|
||||
"height": 20,
|
||||
"width": 30,
|
||||
|
@ -25,6 +26,7 @@ Object {
|
|||
"contentBase64": "eyJfX3NpemUiOnsid2lkdGgiOjMwLCJoZWlnaHQiOjIwfX0=",
|
||||
"contentType": "png",
|
||||
"filePath": "foo@2x.ios.png",
|
||||
"hash": "AGicIEH/IsIy5t7si/9ocI6Ur8s=",
|
||||
"physicalSize": Object {
|
||||
"height": 20,
|
||||
"width": 30,
|
||||
|
|
|
@ -17,6 +17,7 @@ const JsFileWrapping = require('./JsFileWrapping');
|
|||
const Platforms = require('./Platforms');
|
||||
|
||||
const collectDependencies = require('./collectDependencies');
|
||||
const crypto = require('crypto');
|
||||
const defaults = require('../../defaults');
|
||||
const docblock = require('jest-docblock');
|
||||
const generate = require('./generate');
|
||||
|
@ -173,6 +174,10 @@ function transformAsset(
|
|||
assetPath: assetData.assetName,
|
||||
contentBase64: content.toString('base64'),
|
||||
contentType,
|
||||
hash: crypto
|
||||
.createHash('sha1')
|
||||
.update(content)
|
||||
.digest('base64'),
|
||||
filePath,
|
||||
physicalSize: getAssetSize(contentType, content, filePath),
|
||||
platform: assetData.platform,
|
||||
|
|
Loading…
Reference in New Issue