-
Notifications
You must be signed in to change notification settings - Fork 8
Description
Thank you for this fantastic library. I am using this library in a project that uses a WASM build in a non-browser context. This currently does not work without modifications of this library. Compiling for a wasm32 target architecture automatically includes the wasm_bindgen and tsify dependencies and activates the bindgen macros. The resulting binary will include imports needed for JS interop, which are normally provided by the generated JS files. If one tries to execute the binary in an environment (such as wasmer or wasmtime) that does not provide these imports the execution will fail, regardless of whether the JS bindings were necessary in the first place.
Would you consider providing a mechanism to disable the generation of JS bindings even if compiling for the wasm32 architecture?
My proposed solution for this would be to put the binding macros behind a feature and enable the feature by default. This would change nothing for existing users of the library, but will give others the option to explicitly disable the feature and therefore the binding generation. I have verified that this approach works and could provide my modifications. Maybe there are other ways to achieve this; I am by no means a Cargo expert :-)
I would greatly appreciate if you would consider this or any other solution that allows producing WASM binaries that can be used without the JS bindings.