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

Add support for re-exporting crates ✨ #9831

Open
evaspitslines opened this issue Sep 17, 2023 · 5 comments
Open

Add support for re-exporting crates ✨ #9831

evaspitslines opened this issue Sep 17, 2023 · 5 comments
Labels
A-ECS Entities, components, systems, and events C-Usability A simple quality-of-life change that makes Bevy easier to use D-Complex Quite challenging from either a design or technical perspective. Ask for help!

Comments

@evaspitslines
Copy link

I have a crate that reexports bevy :)

use eva_voxel::ecs::system::Resource;

#[derive(Resource)]
struct MyResource {}

fn main() {
    
}

this code does not compile, since the Resource proc macro thinks that it should use bevy_ecs::Resource :(

Could we somehow add support so it can work? 😺

@evaspitslines evaspitslines added C-Enhancement A new feature S-Needs-Triage This issue needs to be labelled labels Sep 17, 2023
@hymm
Copy link
Contributor

hymm commented Sep 17, 2023

I think you should be able to add use exa_voxel as bevy_ecs as a workaround

@evaspitslines
Copy link
Author

yes that is working :) but it would be really great to have it work out of the box
from my understanding, the crate name is retrieved from the bevy manifest, maybe we could add a config for it to take another name 😄

@hymm
Copy link
Contributor

hymm commented Sep 17, 2023

looks like serde has an attribute for this https://serde.rs/container-attrs.html#crate, but I think you'd have to add it for every derive

@evaspitslines
Copy link
Author

the thing is: It would be really nice to have it work out of the box, so that I only need to write the same code as in the example ✨ . I don't know if its possible, but it would be great 😅

@alice-i-cecile alice-i-cecile added A-ECS Entities, components, systems, and events C-Usability A simple quality-of-life change that makes Bevy easier to use D-Complex Quite challenging from either a design or technical perspective. Ask for help! and removed C-Enhancement A new feature S-Needs-Triage This issue needs to be labelled labels Sep 18, 2023
@nicopap
Copy link
Contributor

nicopap commented Sep 19, 2023

It's an unsolved problem. with a macro_rules it just works if you use $crate, but it's not easy with proc macros.

Most crates that export a proc macro have an attribute to the proc macro that allow overwriting the import crate (like @hymm mentioned with serde)

Nothing prevents you from forking bevy_ecs_macros and re-export your own version of the macro that uses your crate's name as the import crate though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events C-Usability A simple quality-of-life change that makes Bevy easier to use D-Complex Quite challenging from either a design or technical perspective. Ask for help!
Projects
None yet
Development

No branches or pull requests

4 participants