Skip to content

Commit

Permalink
Fix EXPORT_ES6 + locateFile
Browse files Browse the repository at this point in the history
`Module['locateFile']` needs to be checked even in `EXPORT_ES6` mode.

In #14135 I did this for `new Worker`, but not for Wasm binary locator, so it broke existing usages of EXPORT_ES6 + custom `locateFile` function.
  • Loading branch information
RReverser committed May 20, 2021
1 parent 9c89909 commit 082d8ac
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/preamble.js
Original file line number Diff line number Diff line change
Expand Up @@ -747,13 +747,17 @@ function instrumentWasmTableWithAbort() {
#endif

#if EXPORT_ES6
// Use bundler-friendly `new URL(..., import.meta.url)` pattern; works in browsers too.
var wasmBinaryFile = new URL('{{{ WASM_BINARY_FILE }}}', import.meta.url).toString();
#else
if (Module['locateFile']) {
#endif
var wasmBinaryFile = '{{{ WASM_BINARY_FILE }}}';
if (!isDataURI(wasmBinaryFile)) {
wasmBinaryFile = locateFile(wasmBinaryFile);
}
#if EXPORT_ES6
} else {
// Use bundler-friendly `new URL(..., import.meta.url)` pattern; works in browsers too.
var wasmBinaryFile = new URL('{{{ WASM_BINARY_FILE }}}', import.meta.url).toString();
}
#endif

function getBinary(file) {
Expand Down

0 comments on commit 082d8ac

Please sign in to comment.