Skip to content

[Web] No way to prevent the default wasm from being bundled #24009

Open
@Eldow

Description

@Eldow

Describe the issue

Hello 👋

Thank you for this great library,

We are facing an issue when specifying custom wasm paths:

ort.env.wasm.wasmPaths = {
  wasm: chrome.runtime.getURL("./test.wasm"),
  mjs: chrome.runtime.getURL("./test.mjs")
};

Then as an application build process, we added a specific build step to output the custom wasm binary and corresponding mjs file into the destination directory.

When running webpack, the bundled output still contains the 10.5MB default wasm (first file in the picture below) shipped with onnxruntime-web and is still referenced in the bundled javascript (second picture).

This increases the size of our extension artifact unnecessarily, that can be consequential and could come as a surprise.

Image Image

Is there a way to properly exclude the default wasm from the bundle when providing a custom one ?

Thank you !

To reproduce

Reproduction sandbox - run pnpm build to generate a new folder in ./dist :
https://codesandbox.io/p/devbox/s4mxt9
In the dist folder, you can see the generated WASM asset and the reference to it in the main.js file.

Urgency

We have a non-ideal workaround in place by not relying on wasmPaths and replacing the default wasm/mjs files directly in the library after building it following the official documentation. Solving this issue would allow us to get rid of this custom integration.

ONNX Runtime Installation

Released Package

ONNX Runtime Version or Commit ID

1.19.2

Execution Provider

'wasm'/'cpu' (WebAssembly CPU)

Metadata

Metadata

Assignees

No one assigned

    Labels

    api:Javascriptissues related to the Javascript APIplatform:webissues related to ONNX Runtime web; typically submitted using template

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions