Skip to content
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

[js/web] allow import .mjs/.wasm file #23487

Merged
merged 2 commits into from
Jan 29, 2025
Merged

[js/web] allow import .mjs/.wasm file #23487

merged 2 commits into from
Jan 29, 2025

Conversation

fs-eire
Copy link
Contributor

@fs-eire fs-eire commented Jan 25, 2025

Description

Allow importing the .mjs and .wasm files.

when using Vite, this enables web app to consume ORT-web for simplify the setup:

import * as ort from 'onnxruntime-web';

import wasmFileUrl from 'onnxruntime-web/.wasm?url';
ort.env.wasm.wasmPaths = { wasm: wasmFileUrl };

@fs-eire fs-eire force-pushed the fs-eire/allow-import-dist branch from cf4a7bd to 990964c Compare January 26, 2025 21:30
@fs-eire fs-eire requested review from Copilot and guschmue January 27, 2025 22:38
@fs-eire fs-eire merged commit bf023ab into main Jan 29, 2025
61 of 65 checks passed
@fs-eire fs-eire deleted the fs-eire/allow-import-dist branch January 29, 2025 00:24
fs-eire added a commit that referenced this pull request Jan 29, 2025
fs-eire added a commit that referenced this pull request Jan 30, 2025
### Description

After some investigation and debug, I decided to follow the recommended
workaround as suggested in vitejs/vite#8427.

### Motivation and Context

There is a known issue with Vite 5.x when using WebAssembly package.
Detail information is in vitejs/vite#8427.

There are previous attempts to fix this problem (#23487). I tried
various ways to make it working out of the box for Vite users but none
of them worked: Some "fixes" did fix the usage of Vite but broke other
use case/bundler and some introduced other issues. Eventually I figured
out that there is no good way to fix this inside ONNX Runtime.

Considering the root cause is inside Vite and it may be fixed in Vite
v6. I think now the best way is to follow the recommended workaround.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants