@@ -63,6 +63,7 @@ export async function instantiateForThread(
6363async function _instantiate (
6464 options
6565) {
66+ const _WebAssembly = options . WebAssembly || WebAssembly ;
6667 const moduleSource = options . module ;
6768/* #if IS_WASI */
6869 const { wasi } = options ;
@@ -98,23 +99,23 @@ async function _instantiate(
9899 let module ;
99100 let instance ;
100101 let exports ;
101- if ( moduleSource instanceof WebAssembly . Module ) {
102+ if ( moduleSource instanceof _WebAssembly . Module ) {
102103 module = moduleSource ;
103- instance = await WebAssembly . instantiate ( module , importObject ) ;
104+ instance = await _WebAssembly . instantiate ( module , importObject ) ;
104105 } else if ( typeof Response === "function" && ( moduleSource instanceof Response || moduleSource instanceof Promise ) ) {
105- if ( typeof WebAssembly . instantiateStreaming === "function" ) {
106- const result = await WebAssembly . instantiateStreaming ( moduleSource , importObject ) ;
106+ if ( typeof _WebAssembly . instantiateStreaming === "function" ) {
107+ const result = await _WebAssembly . instantiateStreaming ( moduleSource , importObject ) ;
107108 module = result . module ;
108109 instance = result . instance ;
109110 } else {
110111 const moduleBytes = await ( await moduleSource ) . arrayBuffer ( ) ;
111- module = await WebAssembly . compile ( moduleBytes ) ;
112- instance = await WebAssembly . instantiate ( module , importObject ) ;
112+ module = await _WebAssembly . compile ( moduleBytes ) ;
113+ instance = await _WebAssembly . instantiate ( module , importObject ) ;
113114 }
114115 } else {
115116 // @ts -expect-error: Type 'Response' is not assignable to type 'BufferSource'
116- module = await WebAssembly . compile ( moduleSource ) ;
117- instance = await WebAssembly . instantiate ( module , importObject ) ;
117+ module = await _WebAssembly . compile ( moduleSource ) ;
118+ instance = await _WebAssembly . instantiate ( module , importObject ) ;
118119 }
119120
120121 swift . setInstance ( instance ) ;
0 commit comments