Skip to content

Commit 35c6ce5

Browse files
authored
[wasm] Don't call .NET runtime if browser refresh script for HotReload is missing (#50138)
1 parent 648f546 commit 35c6ce5

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/BuiltInTools/HotReloadAgent.WebAssembly.Browser/wwwroot/Microsoft.DotNet.HotReload.WebAssembly.Browser.lib.module.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
let isHotReloadEnabled = false;
2+
13
export async function onRuntimeConfigLoaded(config) {
24
// If we have 'aspnetcore-browser-refresh', configure mono runtime for HotReload.
35
if (config.debugLevel !== 0 && globalThis.window?.document?.querySelector("script[src*='aspnetcore-browser-refresh']")) {
6+
isHotReloadEnabled = true;
7+
48
if (!config.environmentVariables["DOTNET_MODIFIABLE_ASSEMBLIES"]) {
59
config.environmentVariables["DOTNET_MODIFIABLE_ASSEMBLIES"] = "debug";
610
}
@@ -14,6 +18,10 @@ export async function onRuntimeConfigLoaded(config) {
1418
}
1519

1620
export async function onRuntimeReady({ getAssemblyExports }) {
21+
if (!isHotReloadEnabled) {
22+
return;
23+
}
24+
1725
const exports = await getAssemblyExports("Microsoft.DotNet.HotReload.WebAssembly.Browser");
1826
await exports.Microsoft.DotNet.HotReload.WebAssembly.Browser.WebAssemblyHotReload.InitializeAsync(document.baseURI);
1927

0 commit comments

Comments
 (0)