{"push_id":2466068485,"size":1,"distinct_size":1,"ref":"refs/heads/master","head":"d67a80591e4e5ab3582943e1f74209b0c2547141","before":"661c59c38f6111949bb50cb9c7676dae1537804a","commits":[{"sha":"d67a80591e4e5ab3582943e1f74209b0c2547141","author":{"name":"Serhii Palash","email":"2911260d9d8d6cc2d7c6f978e0d491f6f4baba2a@gmail.com"},"message":"Add assets to bundle not with asset general hash, but with fileHashes array values for each attached file\n\nThis is fix for bug `assetBundlePatterns error on Android when using sufix like image@2x.png`\nhttps://forums.expo.io/t/assetbundlepatterns-error-on-android-when-using-sufix-like-image-2x-png/6790.\n\nThe bug was because there are could be multiple attached files in one required Asset, but only one file was added in bundle - `asset.files[0]`, and always was used asset general hash, but not this specific file hash.\nThese hashes could be different, in this case there will be broken unnecessary files in bundle, which is also a bug.\n\nAsset has multiple attached files when you have image in three sizes\n\n```\n/assets/img/app-features.png\n/assets/img/app-features@2x.png\n/assets/img/app-features@3x.png\n```\n\nand require it like this\n\n```\n<Image source={require(‘./assets/images/app-features.png’)} />\n```\n\nIn this case Asset object looks like this\n\n<img width=\"981\" alt=\"screen shot 2018-04-07 at 9 56 19 pm\" src=\"https://user-images.githubusercontent.com/14208343/38459120-98ed8e2c-3aae-11e8-920e-1952c068f235.png\">\n\nAs you see Asset general hash is different from Asset files hashes.\n\nIn this case when you do this\n```\nbundledAssets.add('asset_' + asset.hash + (asset.type ? '.' + asset.type : ''));\n```\nyou will add to the bundle file `asset_2d9c23e0c8a503ad84999fc1eeb52acc.png`. But there is no file for Asset general hash and you will add broken file inside bundle.\n\nIt looks like this\n<img width=\"1474\" alt=\"screen shot 2018-04-07 at 10 00 42 pm\" src=\"https://user-images.githubusercontent.com/14208343/38459179-49399096-3aaf-11e8-89b1-53feadabe917.png\">\n\nOnly files with hashes specified in Asset `fileHashes` array always exist.\n\nTo fix this bug you need to go through Asset `fileHashes` array and add to the bundle files for each item in it.\n\nTo test this fix\n```\ngit clone repo https://github.com/serhiipalash/test-assets\ncd test-assets\nyarn\n```\nthen open file `/node_modules/xdl/build/Project.js` and find `_fetchAndUploadAssetsAsync` function in it.\n\nAdd logs\n<img width=\"1163\" alt=\"screen shot 2018-04-07 at 10 09 19 pm\" src=\"https://user-images.githubusercontent.com/14208343/38459273-60c7dc3a-3ab0-11e8-8369-e5a94aa37846.png\">\n\nrun\n```\nnpm start\nnpm publish\n```\n\nYou will see this in Terminal\n<img width=\"1227\" alt=\"screen shot 2018-04-07 at 9 44 00 pm\" src=\"https://user-images.githubusercontent.com/14208343/38459283-7ed9a366-3ab0-11e8-9a68-72dab4e4dfaa.png\">\n\nThen apply fix\n<img width=\"1108\" alt=\"screen shot 2018-04-07 at 10 11 17 pm\" src=\"https://user-images.githubusercontent.com/14208343/38459306-b6e78eda-3ab0-11e8-9f67-6b9fd883ef41.png\">\n\nrun again\n```\nnpm publish\n```\n\nYou will see this in Terminal\n<img width=\"1116\" alt=\"screen shot 2018-04-07 at 9 36 05 pm\" src=\"https://user-images.githubusercontent.com/14208343/38459391-a5df6800-3ab1-11e8-8d5a-284e8d457e2a.png\">\n\nI tested this fix in our project today and all works for image-assets with and without multiple attached files, for fonts, for videos.\n\n<img width=\"1445\" alt=\"screen shot 2018-04-07 at 10 13 13 pm\" src=\"https://user-images.githubusercontent.com/14208343/38459347-1d389864-3ab1-11e8-9dfe-ba353d34d5d7.png\">\n\nCloses expo/xdl#24\n\nfbshipit-source-id: 9e7be59","distinct":true,"url":"https://api.github.com/repos/expo/xdl/commits/d67a80591e4e5ab3582943e1f74209b0c2547141"}]}
{"actor":{"display_login":"expbot"}}