-
Notifications
You must be signed in to change notification settings - Fork 907
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 bundling assets with a path outside of the project root #939
Fix bundling assets with a path outside of the project root #939
Conversation
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: #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
Sounds good, thanks! I'll wait with this one before I release 0.62 of the CLI off master. This is going to go for next React Native release to sync with that diff. |
RN part of the PR was merged on Feb 3rd |
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
Is this backwards compatible? I can see it wasn't picked for 0.62 release (should it be?), so we could merge it to |
Yes, using paths outside the root is currently broken and it doesn't change the behaviour of paths inside the project root. |
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.
Please rebase so that tests appear green and I think we're good merging it :)
4f75146
to
c9249c0
Compare
Done, tests passed! |
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.RN part of this PR: facebook/react-native#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.