Skip to content

Support tree shaking wasm in the rollup plugin #57

@brendandahl

Description

@brendandahl

Describe the feature

When there are unused exports from a Wasm module they should be removed.

One possible way to do this:

  1. Get the unused exports during generateBundle from module.removedExports
  2. Read all the exports from the wasm file
  3. Remove the unused exports from that list
  4. Put those exports in a JSON file in the format that wasm-metacde (from binaryen) understands
  5. Run wasm-metadce on the binary

FWIW, I've done something similar in a emscripten specific plugin here.

Additional information

  • Would you be willing to help implement this feature?

Activity

added a commit that references this issue on Apr 29, 2025
bf9762a
linked a pull request that will close this issue on Apr 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @brendandahl

      Issue actions

        Support tree shaking wasm in the rollup plugin · Issue #57 · unjs/unwasm