prost icon indicating copy to clipboard operation
prost copied to clipboard

[WIP] wasm-bindgen support

Open Tarnadas opened this issue 6 years ago • 3 comments

Hey!

I am trying to add wasm-bindgen support and stumbled across several problems. This PR is still very wip.

  • I don't know how to define a feature for a sub-crate for conditional compilation. See commented out cfg! code
  • wasm-bindgen does not support pub vectors within structs, so I just removed the pub for them (see https://github.com/rustwasm/wasm-bindgen/issues/439)
  • probably the biggest problem so far: oneof gets converted to enums holding data, which isn't supported by wasm-bindgen and it will probably take a lot of effort to support them within wasm-bindgen (see https://github.com/rustwasm/wasm-bindgen/issues/31). It might be easier to change code generation of proto files for oneofs instead

Tarnadas avatar Mar 13 '19 06:03 Tarnadas

Hi sorry for slow feedback - is this still a going concern? I would ideally like prost to be compatible with wasm, but the concerns about enums with data seems like a pretty hard blocker. For context I have no wasm experience, so I don't know if the state of the world has changed in the last 18 months.

danburkert avatar Nov 15 '20 19:11 danburkert

Hey, it doesn't look like anything has changed regarding enums, so a workaround for a WebAssembly version would be required.

I was rather new to Rust when I started this PR and I think I might get this working somehow. As a reference, I will see how other Protobuf libraries in JavaScript do their code generation and try to make something similar for the WebAssembly version.

Tarnadas avatar Nov 24 '20 06:11 Tarnadas

It is better to do this work after wasm-bindgen supporting enums: https://github.com/rustwasm/wasm-bindgen/pull/2631

ImJeremyHe avatar Jan 13 '22 07:01 ImJeremyHe