@@ -716,7 +716,7 @@ function getWasmImports() {
716716 // handle a generated wasm instance, receiving its exports and
717717 // performing other necessary setup
718718 /** @param {WebAssembly.Module= } module*/
719- function receiveInstance ( instance , module ) {
719+ { { { asyncIf ( MAIN_MODULE ) } } } function receiveInstance ( instance , module ) {
720720#if RUNTIME_DEBUG
721721 dbg ( 'receiveInstance' )
722722#endif
@@ -776,21 +776,21 @@ function getWasmImports() {
776776 Module [ 'wasmExports' ] = wasmExports ;
777777#endif
778778
779+ #if ! IMPORTED_MEMORY
780+ updateMemoryViews ( ) ;
781+ #endif
782+
779783#if MAIN_MODULE
780784#if '$LDSO' in addedLibraryItems
781785 LDSO . init ( ) ;
782786#endif
783- loadDylibs ( ) ;
787+ await loadDylibs ( ) ;
784788#endif
785789
786790#if ABORT_ON_WASM_EXCEPTIONS
787791 instrumentWasmTableWithAbort ( ) ;
788792#endif
789793
790- #if ! IMPORTED_MEMORY
791- updateMemoryViews ( ) ;
792- #endif
793-
794794#if PTHREADS || WASM_WORKERS
795795 // We now have the Wasm module loaded up, keep a reference to the compiled module so we can post it to the workers.
796796 wasmModule = module ;
@@ -864,7 +864,7 @@ function getWasmImports() {
864864
865865#if SOURCE_PHASE_IMPORTS
866866 var instance = await WebAssembly . instantiate ( wasmModule , info ) ;
867- var exports = receiveInstantiationResult ( { instance, 'module' :wasmModule } ) ;
867+ var exports = { { { awaitIf ( MAIN_MODULE ) } } } receiveInstantiationResult ( { instance, 'module' :wasmModule } ) ;
868868 return exports ;
869869#else
870870 wasmBinaryFile ??= findWasmBinary ( ) ;
@@ -873,7 +873,7 @@ function getWasmImports() {
873873 dbg ( 'asynchronously preparing wasm' ) ;
874874#endif
875875 var result = await instantiateAsync ( wasmBinary , wasmBinaryFile , info ) ;
876- var exports = receiveInstantiationResult ( result ) ;
876+ var exports = { { { awaitIf ( MAIN_MODULE ) } } } receiveInstantiationResult ( result ) ;
877877 return exports ;
878878#else // WASM_ASYNC_COMPILATION
879879 var result = instantiateSync ( wasmBinaryFile , info ) ;
0 commit comments