-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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 resolving assets outside of the project root #27932
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, I believe you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cpojer is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
This pull request was successfully merged by @janicduplessis in 7deeec7. When will my fix make it into a release? | Upcoming Releases |
Summary: When an asset is outside of the metro project root, it can lead to relative paths like `/assets/../../node_modules/coolpackage/image.png` as the `httpServerLocation`. This can happen for example when using yarn workspaces with hoisted node_modules. This causes issues when bundling on iOS since we use this path in the filesystem. To avoid this we replace `../` with `_` to preserve the uniqueness of the path while avoiding these kind of problematic relative paths. The same logic is used when bundling assets in the rn-cli. CLI part of this PR: react-native-community/cli#939 ## Changelog [General] [Fixed] - Fix resolving assets outside of the project root Pull Request resolved: facebook#27932 Test Plan: Tested that an asset in a hoisted node_modules package doesn't show up before this patch and does after in a release build. Differential Revision: D19690587 Pulled By: cpojer fbshipit-source-id: 8a9c68af04594ce1503a810ecf2e97ef5bfb8004
Summary
When an asset is outside of the metro project root, it can lead to relative paths like
/assets/../../node_modules/coolpackage/image.png
as thehttpServerLocation
. This can happen for example when using yarn workspaces with hoisted node_modules.This causes issues when bundling on iOS since we use this path in the filesystem. To avoid this we replace
../
with_
to preserve the uniqueness of the path while avoiding these kind of problematic relative paths. The same logic is used when bundling assets in the rn-cli.CLI part of this PR: react-native-community/cli#939
Changelog
[General] [Fixed] - Fix resolving assets outside of the project root
Test Plan
Tested that an asset in a hoisted node_modules package doesn't show up before this patch and does after in a release build.