Skip to content

Restore optimization to import functions directly #1636

Closed
@alexcrichton

Description

@alexcrichton

In the recent refactorings to get based on WebIDL bindings an optimization within wasm-bindgen-the-CLI was lost. In many cases we need a JS shim for imported functions, but in some cases we don't need any shim at all and can import the function directly. We should import the relevant function directly into the module if this is the case rather than creating a shim which simply forwards arguments.

It's worth noting as well that as wasm standards progress, we'll get more features for more types which makes this a more important optimization!

Additionally we should also apply a second optimization (which I don't think was ever done) which is to directly import the function from the wasm module if the imported path is a vanilla ES path, not requiring a JS shim for us to move, for example, a global JS type into a module's namespace.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions