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

Make yew's #[derive(..)] macros re-exportable. #1454

Open
AgarwalPragy opened this issue Jul 26, 2020 · 0 comments
Open

Make yew's #[derive(..)] macros re-exportable. #1454

AgarwalPragy opened this issue Jul 26, 2020 · 0 comments
Labels
A-yew-macro Area: The yew-macro crate feature-request A feature request

Comments

@AgarwalPragy
Copy link

AgarwalPragy commented Jul 26, 2020

Describe the feature you'd like

Consider the following structure of nested crates common to a project:

project/
 | --- common/
 | --- feature1/
 | --- feature2/

The common crate re-exports yew for feature crates to use

// project/common/src/lib.rs
pub use yew;
# project/common/Cargo.toml
[dependencies]
yew = "0.17.2"

The features crates use yew via the common crate:

// project/feature1/src/lib.rs
use common::yew::prelude::*;

#[derive(Properties, Clone)]
pub struct Props;
# project/feature1/Cargo.toml
[dependencies]
common = {path="../common"}

Current behavior:
The re-exported derive macros (#[derive(Properties)]) don't work, unless the feature crates explicitly include yew in their respective Cargo.toml

14 | #[derive(Properties, Clone)]
   |          ^^^^^^^^^^ could not find `yew` in `{{root}}`

Additional Context

I encoutered the same behavior of re-exporting not working with serde::{Deserialize, Serialize} (serde-rs/serde#1465)

From discord chat

Simon: This doesn't work because the generated code needs to use members of the Yew crate. There's no way around that...
Teymour: It would be technically possible to get around this, but probably not worth it.
Simon: This could only work if you could somehow rewrite the generated code to depend on mindwiki_core::yew instead of yew
Teymour: We could use a compile-time environment variable to optionally set a custom prefix to use instead of yew but it seems like a lot of extra cruft to introduce.
Simon I'm like 99% sure this would violate at least 3 invariants xD
Pragy: @siku2 won't that be possible by doing crate::?
Simon: It might work but Span::mixed_site has only just hit stable in 1.45 so we aren't using it yet. If you open an issue for this I will look into it some more

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-yew-macro Area: The yew-macro crate feature-request A feature request
Projects
None yet
Development

No branches or pull requests

2 participants