haul icon indicating copy to clipboard operation
haul copied to clipboard

Fix issue with long asset names generated from pnpm paths

Open spion opened this issue 3 years ago • 2 comments

Summary

This PR fixes issue #748

Test plan

Example output when compiling react-navigation in a pnpm project:

68502 % ls drawable-mdpi/  
gation_stack551_a182da6647d2184b7d281770a34a973a_node_modules_reactnavigation_stack_src_views_assets_backiconmask_3.png
m_reactnative0622_686ec919160581136b28b7fe63160a42_node_modules_reactnative_libraries_logbox_ui_logboximages_loader_6.png
native0622_686ec919160581136b28b7fe63160a42_node_modules_reactnative_libraries_logbox_ui_logboximages_alerttriangle_7.png
native0622_686ec919160581136b28b7fe63160a42_node_modules_reactnative_libraries_logbox_ui_logboximages_chevronright_4.png
navigation_stack551_a182da6647d2184b7d281770a34a973a_node_modules_reactnavigation_stack_src_views_assets_backicon_2.png
pm_reactnative0622_686ec919160581136b28b7fe63160a42_node_modules_reactnative_libraries_logbox_ui_logboximages_close_1.png

Might still be an issue if multiple processes or worker threads are running an asset loader module in parallel. Let me know if you'd like a different approach

spion avatar Jul 11 '20 17:07 spion

Thanks for the PR @spion Maybe instead of slicing the string and adding a counter to it, we could hash the full long path into the eg 32 character hash? To simplify the logic we could do this in all cases, not only if the name is longer than 255. Do you know how Metro does this? Or if they are using a hash for assets??

zamotany avatar Jul 13 '20 13:07 zamotany

I think metro is completely incapable at working with pnpm due to its extensive usage of symlinks, so I'm not sure how possible it is to reproduce this there.

What about hashing the full path but still using the basename? I'd imagine a lot of people will appreciate having at least some indication of what the file is about :grinning:

P.S. Any suggestions about which hash to use?

spion avatar Jul 13 '20 15:07 spion