Use BEVY_ASSET_ROOT & CARGO_MANIFEST_DIR to load yarn file#274
Merged
janhohenheim merged 2 commits intoYarnSpinnerTool:mainfrom Feb 2, 2026
Merged
Use BEVY_ASSET_ROOT & CARGO_MANIFEST_DIR to load yarn file#274janhohenheim merged 2 commits intoYarnSpinnerTool:mainfrom
janhohenheim merged 2 commits intoYarnSpinnerTool:mainfrom
Conversation
Collaborator
|
@andriyDev mind helping me out here for a second? |
andriyDev
approved these changes
Feb 1, 2026
andriyDev
left a comment
There was a problem hiding this comment.
Overall I think this is fine! I think calling get_base_path is better than forking this for sure (to stay in sync).
| #[cfg(not(target_arch = "wasm32"))] | ||
| fn register_asset_root(&mut self) -> &mut Self { | ||
| let asset_plugin = get_asset_plugin(self); | ||
| let mut path = FileAssetReader::get_base_path(); |
There was a problem hiding this comment.
Can we only conditionally compile these two lines instead of the whole function? I think it's simpler that way (than acting like these are totally different).
Contributor
Author
There was a problem hiding this comment.
Something like this ?
fn register_asset_root(&mut self) -> &mut Self {
let asset_plugin = get_asset_plugin(self);
let path_str = asset_plugin.file_path.clone();
#[cfg(not(target_arch = "wasm32"))]
let path = FileAssetReader::get_base_path().join(path_str);
#[cfg(target_arch = "wasm32")]
let path = PathBuf::from(path_str);
self.insert_resource(AssetRoot(path))
}
Contributor
Author
|
Not tested on wasm32 though |
janhohenheim
approved these changes
Feb 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
To solve #271,
register_asser_rootneeds to take into account the absolute path that may be included through BEVY_ASSET_ROOT or CARGO_MANIFEST_DIR.The only way I found to solve this is to use the FileAssetReader which is not available in wasm32 builds.
Or we could integrate part of
get_base_pathinsideregister_asset_root()as in:However, I'm not an expert in wasm32 build and I don't know if std::env is available there.
Which version do you prefer ?