diff --git a/src/preamble.js b/src/preamble.js index 5e31b92d017a2..d8d1b1b269bf9 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -603,8 +603,13 @@ function instrumentWasmTableWithAbort() { } #endif +#if SINGLE_FILE +// In SINGLE_FILE mode the wasm binary is encoded inline here as a data: URL. +var wasmBinaryFile = '{{{ WASM_BINARY_FILE }}}'; +#else +var wasmBinaryFile; function findWasmBinary() { -#if EXPORT_ES6 && USE_ES6_IMPORT_META && !SINGLE_FILE && !AUDIO_WORKLET +#if EXPORT_ES6 && USE_ES6_IMPORT_META && !AUDIO_WORKLET if (Module['locateFile']) { #endif var f = '{{{ WASM_BINARY_FILE }}}'; @@ -614,7 +619,7 @@ function findWasmBinary() { } #endif return f; -#if EXPORT_ES6 && USE_ES6_IMPORT_META && !SINGLE_FILE && !AUDIO_WORKLET // In single-file mode, repeating WASM_BINARY_FILE would emit the contents again. For an Audio Worklet, we cannot use `new URL()`. +#if EXPORT_ES6 && USE_ES6_IMPORT_META && !AUDIO_WORKLET // In single-file mode, repeating WASM_BINARY_FILE would emit the contents again. For an Audio Worklet, we cannot use `new URL()`. } #if ENVIRONMENT_MAY_BE_SHELL if (ENVIRONMENT_IS_SHELL) @@ -624,8 +629,7 @@ function findWasmBinary() { return new URL('{{{ WASM_BINARY_FILE }}}', import.meta.url).href; #endif } - -var wasmBinaryFile; +#endif function getBinarySync(file) { if (file == wasmBinaryFile && wasmBinary) { @@ -1079,7 +1083,9 @@ function getWasmImports() { } #endif +#if !SINGLE_FILE wasmBinaryFile ??= findWasmBinary(); +#endif #if WASM_ASYNC_COMPILATION #if RUNTIME_DEBUG diff --git a/test/other/test_unoptimized_code_size.js.size b/test/other/test_unoptimized_code_size.js.size index cf69ddfe4a77e..c92d2e5e9cfeb 100644 --- a/test/other/test_unoptimized_code_size.js.size +++ b/test/other/test_unoptimized_code_size.js.size @@ -1 +1 @@ -53981 +53980 diff --git a/test/other/test_unoptimized_code_size_no_asserts.js.size b/test/other/test_unoptimized_code_size_no_asserts.js.size index 2aba7946a2888..27713e9b085b4 100644 --- a/test/other/test_unoptimized_code_size_no_asserts.js.size +++ b/test/other/test_unoptimized_code_size_no_asserts.js.size @@ -1 +1 @@ -29401 +29400 diff --git a/test/other/test_unoptimized_code_size_strict.js.size b/test/other/test_unoptimized_code_size_strict.js.size index b958a7dffaa33..b9b5998b7a2be 100644 --- a/test/other/test_unoptimized_code_size_strict.js.size +++ b/test/other/test_unoptimized_code_size_strict.js.size @@ -1 +1 @@ -52777 +52776