diff --git a/src/mono/wasm/runtime/loader/blazor/_Integration.ts b/src/mono/wasm/runtime/loader/blazor/_Integration.ts index 393658b67668a7..27d99d92ea5cfc 100644 --- a/src/mono/wasm/runtime/loader/blazor/_Integration.ts +++ b/src/mono/wasm/runtime/loader/blazor/_Integration.ts @@ -73,7 +73,7 @@ export function setupModuleForBlazor(module: DotnetModuleInternal) { return undefined; }; - module.downloadResource = downloadResource; + loaderHelpers.downloadResource = downloadResource; // polyfills were already assigned module.disableDotnet6Compatibility = false; } diff --git a/src/mono/wasm/runtime/loader/config.ts b/src/mono/wasm/runtime/loader/config.ts index 655f250a5c4abe..af9d96c60dc65a 100644 --- a/src/mono/wasm/runtime/loader/config.ts +++ b/src/mono/wasm/runtime/loader/config.ts @@ -80,16 +80,20 @@ export async function mono_wasm_load_config(module: DotnetModuleInternal): Promi } if (loaderHelpers.diagnosticTracing) console.debug("MONO_WASM: mono_wasm_load_config"); try { - const resolveSrc = loaderHelpers.locateFile(configFilePath); - const configResponse = await loaderHelpers.fetch_like(resolveSrc); - const loadedAnyConfig: any = (await configResponse.json()) || {}; - if (loadedAnyConfig.resources) { - await initializeBootConfig(BootConfigResult.fromFetchResponse(configResponse, loadedAnyConfig as BootJsonData), module); + if (loaderHelpers.config.startupOptions && loaderHelpers.config.startupOptions.loadBootResource) { + // If we have custom loadBootResource + await loadBootConfig(loaderHelpers.config, module); } else { - const loadedConfig = loadedAnyConfig as MonoConfigInternal; - if (loaderHelpers.config.startupOptions && loaderHelpers.config.startupOptions.loadBootResource) { - await loadBootConfig(loaderHelpers.config, module); + // Otherwise load using fetch_like + const resolveSrc = loaderHelpers.locateFile(configFilePath); + const configResponse = await loaderHelpers.fetch_like(resolveSrc); + const loadedAnyConfig: any = (await configResponse.json()) || {}; + if (loadedAnyConfig.resources) { + // If we found boot config schema + await initializeBootConfig(BootConfigResult.fromFetchResponse(configResponse, loadedAnyConfig as BootJsonData), module); } else { + // Otherwise we found mono config schema + const loadedConfig = loadedAnyConfig as MonoConfigInternal; if (loadedConfig.environmentVariables && typeof (loadedConfig.environmentVariables) !== "object") throw new Error("Expected config.environmentVariables to be unset or a dictionary-style object"); deep_merge_config(loaderHelpers.config, loadedConfig);