-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Do not generate bindings for dependencies #1231
Comments
Thanks for the report! This is somewhat nontrivial to do right now, as the transitive behavior of wasm-bindgen is actually intentional. I suspect, though, that like with normal Rust libraries compiled for C it's "best practice" to avoid We could explore an option like this perhaps, but the information isn't currently available to the CLI tool. Additionally it's not clear I think if we want this long-term because it may end up breaking intermediate dependencies accidentally in some cases. |
Thanks for the reply. We have something like you described, but in the opposite way - enabled by default, feature can disable it. The reason is wasm-pack & this issue. Once 0.6.1 is released, we will modify it, so, by default |
Ah ok makes sense! In that case I think it's probably best to fix it via that, but otherwise this seems reasonable to have as a feature request at least (even if it's not the default behavior) so let's leave it open |
Hi, I have a related question. Is it possible to explicitly make bindings for something in a dependency crate from the dependent crate? It would be something like #[wasm_bindgen]
pub use dep_crate::SomeStruct; This way, the dependency doesn't need to know anything about wasm-bindgen, and the dependent crate is working like a facade. |
Unfortunately, no. The macro runs over the AST, so it can't resolve that and figure out how to generate bindings, it needs the source code itself. |
I see, thanks for the clarification. |
The question really is how to design an interface to control this. E.g. a CLI flag or something that allows more fine-grained control. See also rust-lang/rust#98449. |
I have two crates -
reconfix
andcdsl
. The former one depends on the later one:cdsl
crate can be used as a Rust crate and it also contains bindings gated viacfg(target_arch = "wasm32")
. NPM package with proper bindings can be generated.Now I have a
reconfix
crate, which does usecdsl
as a dependency. But when I generate bindings for thereconfix
crate, all bindings (JS functions) from thecdsl
crate are in thereconfix
bindings as well.Example:
cdsl
contains JS functiongenerate_ui
reconfix
hascdsl
as a dependencyreconfix
does not contain JS functiongenerate_ui
reconfix
does containgenerate_ui
function, which is something I do not want, it behaves like implicitpub use ...
reexportsIs there a way how to disable this behavior? For now, I introduced
disable-wasm-bindings
feature in thecdsl
crate. But it's nothing I like or I consider as a good solution. What's the recommended way? Should I splitcdsl
in two crates, likecdsl
(without wasm bindings) andcdsl-wasm
crate, which will act as a bridge between Rust & JS only?The text was updated successfully, but these errors were encountered: