Skip to content

Parameter maybe_memory should be optional #2133

Closed
@d3lm

Description

@d3lm

Describe the Bug

I have noticed that when the compilation target is web that the maybe_parameter of the initi(input, maybe_memory) is required. The name implies that it might be missing and especially for the first call to init it's most likely missing if input is a string and the module is fetched. Only subsequent calls might have memory. Maybe we change the type of this to also accept null or undefined or mark it as optional.

I think it would make sense to have a sanity check in load that, if module is not a function nor a Response object, meaning it's a WebAssembly module, then we add a check to ensure that maybe_memory is not undefined.

Alternatively, we can pass null! for memory_memory but to me this feels hacky.

Steps to Reproduce

  1. Compile Rust to wasm32-unknown-unknown with target being web

If there is a solution to this and a clear path, I am volunteering to work on a PR to get this resolved.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions