Exports with #[wasm_bindgen(js_name = default)]
gets exported as fn _default
#3929
Labels
#[wasm_bindgen(js_name = default)]
gets exported as fn _default
#3929
Uh oh!
There was an error while loading. Please reload this page.
Describe the Bug
I'm trying to create a plugin for the javascript project EventCatalog in Rust with wasm_bindgen.
Their plugin system is fairly simple and it works by:
require
your package/plugin that's defined in the config file and calls the default exported function, i.e. whats exported withexport default ...
in the main module of the added nodejs package. For the curios you can find the code for the plugin loading code here.I tried to create my plugin with the following code:
Unfortunately the above function gets exported as
_default
instead ofdefault
and the generated JS code (with--target nodejs
) looks like this:which means that
EventCatalog
fails to call my plugin. This issue is very much related to #3012 and is just the other side of the coin. I think it's reasonable that if you can importfn default
, you should also be able to exportfn default
.Expected Behavior
The following Rust function
should be exported as
default
and not_default
and the generated javascript code should be:Additional Context
I'll create a PR soon (PR created #3930)
The text was updated successfully, but these errors were encountered: