-
Notifications
You must be signed in to change notification settings - Fork 3k
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] Feature Request: workaround for bundlers when using onnxruntime-web #22615
Labels
api:Javascript
issues related to the Javascript API
feature request
request for unsupported feature or enhancement
platform:web
issues related to ONNX Runtime web; typically submitted using template
Comments
fs-eire
added
the
platform:web
issues related to ONNX Runtime web; typically submitted using template
label
Oct 26, 2024
there are workarounds for issue 3 - but they involve patching this package to remove the |
This was referenced Oct 28, 2024
fs-eire
added a commit
that referenced
this issue
Oct 29, 2024
### Description This change resolves issue No.3 described in #22615
sophies927
added
the
feature request
request for unsupported feature or enhancement
label
Oct 31, 2024
ishwar-raut1
pushed a commit
to ishwar-raut1/onnxruntime
that referenced
this issue
Nov 19, 2024
### Description This change resolves issue No.3 described in microsoft#22615
Webpack ESM support tracking: webpack/webpack#17121 |
ankitm3k
pushed a commit
to intel/onnxruntime
that referenced
this issue
Dec 11, 2024
### Description This change resolves issue No.3 described in microsoft#22615
ankitm3k
pushed a commit
to intel/onnxruntime
that referenced
this issue
Dec 11, 2024
### Description This change resolves issue No.3 described in microsoft#22615
ankitm3k
pushed a commit
to intel/onnxruntime
that referenced
this issue
Dec 11, 2024
### Description This change resolves issue No.3 described in microsoft#22615
Tracking: Add #23175 for it easier to verify changes of package export. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
api:Javascript
issues related to the Javascript API
feature request
request for unsupported feature or enhancement
platform:web
issues related to ONNX Runtime web; typically submitted using template
Summary
This issue is created to track the status of onnxruntime-web's workaround for bundlers.
What is workaround for bundlers and why?
workaround for bundlers means extra codes that required to make onnxruntime-web as a library consumable by a web app or other libraries, while those extra codes are supposed to be unnecessary but exists because of various reasons.
What are the known issues:
import.meta.url
as a runtime JavaScript expression, is usually rewritten into a static string starts with "file://" by WebPack as a default behavior. A few other bundlers followed this behvior. This means it is very difficult to use ESM dynamic import in the implementation.Vite development mode does not support "real" ESM. It uses some complicated steps to transcript the ESM sources into IIFE/cjs. [js/web] make ort-web export compatible with webpack #22196 tries to fix this but the fix is incompatible with Vite release mode.
Some framework (eg. SvelteKit) always load onnxruntime-web in a Node.js context even if SSR is disabled . [Web] When the "node" condition path in exports is null vite (+svelte) build will wrongly throw a "No known conditions for" error #22361 (comment)
Emscripten is not able to generate both ESM/commonJS glue file in a build. ([Feature Request] Support building for both UMD/ESM emscripten-core/emscripten#21899)
Why is it difficult to fix:
It's all about dynamic loading with bundler involved.
onnxruntime-web has 4 dynamic loading target:
Considering the following requirements:
It's not hard to conclude that:
For example:
UMD format cannot be supported in CSP. This is because:
proxy worker is not well supported when using with multi-threading. This is because:
new Worker(new URL("ort.min.mjs", import.meta.url), {type: "module"})
, and webpack will use its builtin worker loader to load the worker as a static loaded module.There are more case that makes onnxruntime-web not working out-of-box in different combinations of dev frameworks, bundlers, dev/prod modes and so on, and one fix for a specific usage may even break a specific existing working usage.
It seems that there is no way to make every use scenario work. Need to track issues and find workaround for each.
The text was updated successfully, but these errors were encountered: