Skip to content

Commit c57d447

Browse files
committed
[web] fix usage of wasmBinary together with a blob URL for .mjs
1 parent a98c912 commit c57d447

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

js/web/lib/wasm/wasm-factory.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,13 @@ export const initializeWebAssembly = async (flags: Env.WebAssemblyFlags): Promis
194194
if (wasmBinaryOverride) {
195195
// Set a custom buffer which contains the WebAssembly binary. This will skip the wasm file fetching.
196196
config.wasmBinary = wasmBinaryOverride;
197+
198+
// Offer an implementation of locateFile() that returns the file name directly. This helps to avoid an error
199+
// thrown later from the following code when `import.meta.url` is a blob URL:
200+
// ```
201+
// return new URL("ort-wasm-simd-threaded.jsep.wasm", import.meta.url).href;
202+
// ```
203+
config.locateFile = (fileName) => fileName;
197204
} else if (wasmPathOverride || wasmPrefixOverride) {
198205
// A callback function to locate the WebAssembly file. The function should return the full path of the file.
199206
//

0 commit comments

Comments
 (0)