-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Web] Latest version does nonstandard imports #20978
Comments
@KTibow thank you for reporting this issue. I am not very familiar with Vite. I want to understand more details about the problem. The new version of ORT Web uses dynamic import to load file |
The import function is supported in Vite to some degree. * technicality: Vite isn't a bundler in itself, it uses Rollup, esbuild, and soon a rewrite of Rollup to bundle the code |
The fundamental reason of why I uses dynamic import is becaues Emscripten does not support to generate both UMD/ESM glue for a Wasm target - you have to choose either. This means I have the following options:
The option (1) not only doubled the package size for technically unnecessary reason, but also makes the deployment more complicated. A mismatch will not work and adds quite steps into troubleshooting. I am currently using (2) to build ESM and import it in both UMD/ESM bundle. |
Based on the reason above, I expect the bundler to leave the dynamic import as-is, to keep the dynamic import behavior. |
I'm a bit confused by how this would be possible. I have a suspicion, but I'd like to see the file structure of the bundled files so I can confirm/deny it. |
https://github.com/microsoft/onnxruntime/tree/main/js/web/test/e2e The E2E folder contains bundler test for webpack, rollup and percel |
@KTibow you can alternatively import ORT Web in ESM. In latest main branch, dynamic import is disabled by default when you consume ORT Web as ESModule. |
Works in my tests 👍 |
Describe the issue
The latest version of the web runtime does a lot of nonstandard importing of WASM that doesn't work with Vite.
If I don't configure it at all, it tries to fetch it from the shared directory of bundled JS. This does not work:
If I configure it to use my own static directory, it tries to import JS from it, which does not work:
Instead, the runtime should simply import the files so that they can be bundled by all bundlers.
To reproduce
pnpm install [email protected]
import { InferenceSession } from "onnxruntime-web/webgpu";
Urgency
This is a regression; this worked when you didn't also have to host JS. This blocks me from using the latest version.
ONNX Runtime Installation
Built from Source
ONNX Runtime Version or Commit ID
1.19.0-dev.20240604-3dd6fcc089
Execution Provider
'wasm'/'cpu' (WebAssembly CPU), 'webgpu' (WebGPU)
The text was updated successfully, but these errors were encountered: