Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with long asset names generated from pnpm paths #752

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

spion
Copy link

@spion spion commented Jul 11, 2020

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

@zamotany
Copy link
Contributor

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??

@spion
Copy link
Author

spion commented Jul 13, 2020

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 😀

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants