File tree Expand file tree Collapse file tree 5 files changed +15
-10
lines changed Expand file tree Collapse file tree 5 files changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -976,8 +976,9 @@ export class JSBuilder extends ExportsWalker {
976976 }
977977 sb . push ( `} = await (async url => instantiate(
978978 await (async () => {
979- try { return await globalThis.WebAssembly.compileStreaming(globalThis.fetch(url)); }
980- catch { return globalThis.WebAssembly.compile(await (await import("node:fs/promises")).readFile(url)); }
979+ const isNodeOrBun = typeof process != "undefined" && process.versions != null && (process.versions.node != null || process.versions.bun != null);
980+ if (isNodeOrBun) { return globalThis.WebAssembly.compile(await (await import("node:fs/promises")).readFile(url)); }
981+ else { return await globalThis.WebAssembly.compileStreaming(globalThis.fetch(url)); }
981982 })(), {
982983` ) ;
983984 let needsMaybeDefault = false ;
Original file line number Diff line number Diff line change @@ -553,8 +553,9 @@ export const {
553553 fn,
554554} = await ( async url => instantiate (
555555 await ( async ( ) => {
556- try { return await globalThis . WebAssembly . compileStreaming ( globalThis . fetch ( url ) ) ; }
557- catch { return globalThis . WebAssembly . compile ( await ( await import ( "node:fs/promises" ) ) . readFile ( url ) ) ; }
556+ const isNodeOrBun = typeof process != "undefined" && process . versions != null && ( process . versions . node != null || process . versions . bun != null ) ;
557+ if ( isNodeOrBun ) { return globalThis . WebAssembly . compile ( await ( await import ( "node:fs/promises" ) ) . readFile ( url ) ) ; }
558+ else { return await globalThis . WebAssembly . compileStreaming ( globalThis . fetch ( url ) ) ; }
558559 } ) ( ) , {
559560 }
560561) ) ( new URL ( "esm.debug.wasm" , import . meta. url ) ) ;
Original file line number Diff line number Diff line change @@ -553,8 +553,9 @@ export const {
553553 fn,
554554} = await ( async url => instantiate (
555555 await ( async ( ) => {
556- try { return await globalThis . WebAssembly . compileStreaming ( globalThis . fetch ( url ) ) ; }
557- catch { return globalThis . WebAssembly . compile ( await ( await import ( "node:fs/promises" ) ) . readFile ( url ) ) ; }
556+ const isNodeOrBun = typeof process != "undefined" && process . versions != null && ( process . versions . node != null || process . versions . bun != null ) ;
557+ if ( isNodeOrBun ) { return globalThis . WebAssembly . compile ( await ( await import ( "node:fs/promises" ) ) . readFile ( url ) ) ; }
558+ else { return await globalThis . WebAssembly . compileStreaming ( globalThis . fetch ( url ) ) ; }
558559 } ) ( ) , {
559560 }
560561) ) ( new URL ( "esm.release.wasm" , import . meta. url ) ) ;
Original file line number Diff line number Diff line change @@ -162,8 +162,9 @@ export const {
162162 takesFunction,
163163} = await ( async url => instantiate (
164164 await ( async ( ) => {
165- try { return await globalThis . WebAssembly . compileStreaming ( globalThis . fetch ( url ) ) ; }
166- catch { return globalThis . WebAssembly . compile ( await ( await import ( "node:fs/promises" ) ) . readFile ( url ) ) ; }
165+ const isNodeOrBun = typeof process != "undefined" && process . versions != null && ( process . versions . node != null || process . versions . bun != null ) ;
166+ if ( isNodeOrBun ) { return globalThis . WebAssembly . compile ( await ( await import ( "node:fs/promises" ) ) . readFile ( url ) ) ; }
167+ else { return await globalThis . WebAssembly . compileStreaming ( globalThis . fetch ( url ) ) ; }
167168 } ) ( ) , {
168169 }
169170) ) ( new URL ( "noExportRuntime.debug.wasm" , import . meta. url ) ) ;
Original file line number Diff line number Diff line change @@ -162,8 +162,9 @@ export const {
162162 takesFunction,
163163} = await ( async url => instantiate (
164164 await ( async ( ) => {
165- try { return await globalThis . WebAssembly . compileStreaming ( globalThis . fetch ( url ) ) ; }
166- catch { return globalThis . WebAssembly . compile ( await ( await import ( "node:fs/promises" ) ) . readFile ( url ) ) ; }
165+ const isNodeOrBun = typeof process != "undefined" && process . versions != null && ( process . versions . node != null || process . versions . bun != null ) ;
166+ if ( isNodeOrBun ) { return globalThis . WebAssembly . compile ( await ( await import ( "node:fs/promises" ) ) . readFile ( url ) ) ; }
167+ else { return await globalThis . WebAssembly . compileStreaming ( globalThis . fetch ( url ) ) ; }
167168 } ) ( ) , {
168169 }
169170) ) ( new URL ( "noExportRuntime.release.wasm" , import . meta. url ) ) ;
You can’t perform that action at this time.
0 commit comments