diff --git a/libsquoosh/src/emscripten-utils.ts b/libsquoosh/src/emscripten-utils.ts index 428be004..a6481508 100644 --- a/libsquoosh/src/emscripten-utils.ts +++ b/libsquoosh/src/emscripten-utils.ts @@ -10,13 +10,16 @@ export function pathify(path: string): string { export function instantiateEmscriptenWasm( factory: EmscriptenWasm.ModuleFactory, path: string, - workerWasm: string = '', + workerJS: string = '', ): Promise { return factory({ locateFile(requestPath) { + // The glue code generated by emscripten uses the original + // file names of the worker file and the wasm binary. + // These will have changed in the bundling process and + // we need to inject them here. if (requestPath.endsWith('.wasm')) return pathify(path); - if (requestPath.endsWith('.worker.js')) - return new URL(workerWasm).pathname; + if (requestPath.endsWith('.worker.js')) return new URL(workerJS).pathname; return requestPath; }, });