assemblyscript icon indicating copy to clipboard operation
assemblyscript copied to clipboard

Missing function with raw bindings

Open jonathannorris opened this issue 2 years ago • 2 comments

Hey AS team,

Seems like the compiler isn't exporting functions that do not have and input parameters when run in --bindings raw mode.

For example we have a simple function without any input parameters: image

It shows up in the .wat and .map files: image

Also in the .ts type description: image

but doesn't show up in the generated .js bindings.

jonathannorris avatar Sep 19 '22 16:09 jonathannorris

Functions without a need for glue code come directly from the .wasm file, while functions that need glue code are present in the .js file, wrapping their respective .wasm functions. Unless this is buggy, the final exports object should show all of them.

dcodeIO avatar Sep 19 '22 16:09 dcodeIO

For context, this method was exported when we were previously using the ESM bindings, but do a whole host of issues with the support for ESM we decided to switch back to Common JS. So I would expect that all exported functions would be available to be called from JS using the --bindings raw, especially if the function is part of the types exported in the .d.ts file.

jonathannorris avatar Sep 19 '22 17:09 jonathannorris

Perhaps to clarify: Unless there is a deeper issue, which I don't see any indications for, the function in question in fact exists, but only in the .wasm, not in the accompanying .js file. It does not show up in the .js file because it is so simple that it does not require wrapping of arguments or similar, and is instead immediately re-exported from the .wasm file. The .d.ts describes the combination of both files.

dcodeIO avatar Oct 17 '22 07:10 dcodeIO

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in one week if no further activity occurs. Thank you for your contributions!

github-actions[bot] avatar Nov 16 '22 23:11 github-actions[bot]