Skip to content

One generated wasm to rule them allΒ #2265

Open
@jordy25519

Description

@jordy25519

Motivation

Create a single, isomorphic JS package using wasm-bindgen and tooling.

Proposed Solution

Generate the wasm import table in a consistent or configurable way so that the wasm binary may be used by any JS target runtime.

Maybe there is a way to provide a core wasm file with the main logic and generate only "glue" wasm files for each target which provide the right import shims.

Alternatives

It is possible to do this using wasm-pack or manual build scripts and other glue code the downside of this, in my understanding, is it requires multiple wasm binaries, one for each target, which unnecessarily bloats the final package size.

Additional Context

Idea came from the observation that the generated wasm for --target=node and --target=browser produce
the same binary apart from imports table (converted to wat):
Screen Shot 2020-07-31 at 10 14 11 AM

I don't know dark js arts so maybe there's any easier way to do this from js glue code only but I could not find / comprehend that during my research into this.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions