@@ -307,22 +307,6 @@ async function createEmscriptenModuleInstance(resourceLoader: WebAssemblyResourc
307
307
MONO = mono ;
308
308
IMPORTS = imports ;
309
309
310
- // Override the mechanism for fetching the main wasm file so we can connect it to our cache
311
- const instantiateWasm = ( wasmImports , successCallback ) => {
312
- ( async ( ) => {
313
- let compiledInstance : WebAssembly . Instance ;
314
- try {
315
- const dotnetWasmResource = await wasmBeingLoaded ;
316
- compiledInstance = await compileWasmModule ( dotnetWasmResource , wasmImports ) ;
317
- } catch ( ex ) {
318
- printErr ( ( ex as Error ) . toString ( ) ) ;
319
- throw ex ;
320
- }
321
- successCallback ( compiledInstance ) ;
322
- } ) ( ) ;
323
- return [ ] ; // No exports
324
- } ;
325
-
326
310
const onRuntimeInitialized = ( ) => {
327
311
if ( ! icuDataResource ) {
328
312
// Use invariant culture if the app does not carry icu data.
@@ -520,12 +504,20 @@ async function createEmscriptenModuleInstance(resourceLoader: WebAssemblyResourc
520
504
521
505
const dotnetModuleConfig : DotnetModuleConfig = {
522
506
...moduleConfig ,
507
+ config : {
508
+ assets : [
509
+ {
510
+ behavior : 'dotnetwasm' ,
511
+ name : 'dotnet.wasm' ,
512
+ pendingDownload : wasmBeingLoaded ,
513
+ } ,
514
+ ] ,
515
+ } as any ,
523
516
disableDotnet6Compatibility : false ,
524
517
preRun : [ preRun , ...existingPreRun ] ,
525
518
postRun : [ postRun , ...existingPostRun ] ,
526
519
print,
527
520
printErr,
528
- instantiateWasm,
529
521
onRuntimeInitialized,
530
522
} ;
531
523
@@ -651,31 +643,6 @@ async function loadICUData(icuDataResource: LoadingResource): Promise<void> {
651
643
Module . removeRunDependency ( runDependencyId ) ;
652
644
}
653
645
654
- async function compileWasmModule ( wasmResource : LoadingResource , imports : any ) : Promise < WebAssembly . Instance > {
655
- const wasmResourceResponse = await wasmResource . response ;
656
-
657
- // The instantiateStreaming spec explicitly requires the following exact MIME type (with no trailing parameters, etc.)
658
- // https://webassembly.github.io/spec/web-api/#dom-webassembly-instantiatestreaming
659
- const hasWasmContentType = wasmResourceResponse . headers ?. get ( 'content-type' ) === 'application/wasm' ;
660
-
661
- if ( hasWasmContentType && typeof WebAssembly . instantiateStreaming === 'function' ) {
662
- // We can use streaming compilation. We know this shouldn't fail due to the content-type header being wrong,
663
- // as we already just checked that. So if this fails for some other reason we'll treat it as fatal.
664
- const streamingResult = await WebAssembly . instantiateStreaming ( wasmResourceResponse , imports ) ;
665
- return streamingResult . instance ;
666
- } else {
667
- if ( ! hasWasmContentType ) {
668
- // In most cases the developer should fix this. It's unusual enough that we don't mind logging a warning each time.
669
- console . warn ( 'WebAssembly resource does not have the expected content type "application/wasm", so falling back to slower ArrayBuffer instantiation.' ) ;
670
- }
671
-
672
- // Fall back on ArrayBuffer instantiation.
673
- const arrayBuffer = await wasmResourceResponse . arrayBuffer ( ) ;
674
- const arrayBufferResult = await WebAssembly . instantiate ( arrayBuffer , imports ) ;
675
- return arrayBufferResult . instance ;
676
- }
677
- }
678
-
679
646
function changeExtension ( filename : string , newExtensionWithLeadingDot : string ) {
680
647
const lastDotIndex = filename . lastIndexOf ( '.' ) ;
681
648
if ( lastDotIndex < 0 ) {
0 commit comments