Skip to content

fix(js): copy onnxruntime-web .mjs files alongside .wasm in webpack configs - #586

Open
Reginald Alfret V (reginaldalfret) wants to merge 1 commit into
microsoft:mainfrom
reginaldalfret:fix/519-webpack-copy-ort-wasm-mjs
Open

Reginald Alfret V (reginaldalfret) wants to merge 1 commit into
microsoft:mainfrom
reginaldalfret:fix/519-webpack-copy-ort-wasm-mjs

Conversation

@reginaldalfret

Copy link
Copy Markdown

Description

In js/sd-turbo, js/segment-anything, js/ort-whisper, and js/quick-start_onnxruntime-web-bundler, webpack was configured to only copy node_modules/onnxruntime-web/dist/*.wasm to the distribution directory. However, onnxruntime-web with WebGPU/JSEP and threaded WASM requires companion .mjs modules (such as ort-wasm-simd-threaded.jsep.mjs and ort-wasm-simd-threaded.mjs) at runtime. Because these .mjs files were missing from dist/, running the web examples in browser failed with:
TypeError: Failed to resolve module specifier dist/ort-wasm-simd-threaded.jsep.mjs (#519)
or
failed to fetch ort-wasm-simd-threaded.mjs (#461).

This PR updates the Webpack configuration for all 4 JS examples to copy both *.wasm and *.mjs files from node_modules/onnxruntime-web/dist/ to the destination directory.

Motivation and Context

Fixes #519
Fixes #461

Verification

  • Tested npm run build in js/sd-turbo after installing dependencies, verifying that all .mjs files (including ort-wasm-simd-threaded.jsep.mjs and ort-wasm-simd-threaded.mjs) along with .wasm binaries are copied properly into dist/.
  • Verified formatting and checked for trailing whitespace with git diff --check.

…onfigs (fixes microsoft#519, microsoft#461)

Signed-off-by: Reginald Alfret <reginaldalfret@gmail.com>
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.

Stable diffusion web example fails due to missing file Error in ort-whisper example — failed to fetch ort-wasm-simd-threaded.mjs

1 participant