You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think it would be simpler to call "await init()" and export wasm.memory from out_dir/module_name.js instead of exporting this init function and leaving it to the user to call init() for access to memory from their js.
Current:
Generated js footer:
export { initSync }
export default init;
Code to use it:
import init, { Universe } from './out_dir/module_name.js'
let wasm = await init();
let memory = wasm.memory;
Proposed:
Generated js footer:
await init()
export let memory = wasm.memory
Code to use it:
import { Universe, memory } from './out_dir/module_name.js'
It's also a possibility to move the current generated js to the _bg.js file and put these 3 new proposed lines in its own js file similar to what is done for the nodejs target. Is there any reason we wouldn't prefer this approach? I have already made the necessary changes to wasm-bindgen in a local clone of the repo and tested it. I'm just looking for any feedback on if this is a good change or not before I go forward and create a pull request.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I think it would be simpler to call "await init()" and export wasm.memory from out_dir/module_name.js instead of exporting this init function and leaving it to the user to call init() for access to memory from their js.
Current:
Generated js footer:
Code to use it:
Proposed:
Generated js footer:
Code to use it:
It's also a possibility to move the current generated js to the _bg.js file and put these 3 new proposed lines in its own js file similar to what is done for the nodejs target. Is there any reason we wouldn't prefer this approach? I have already made the necessary changes to wasm-bindgen in a local clone of the repo and tested it. I'm just looking for any feedback on if this is a good change or not before I go forward and create a pull request.
Beta Was this translation helpful? Give feedback.
All reactions