Skip to content

Commit d5a9658

Browse files
authored
Fix issues preventing hot reload for Blazor WASM (#31108)
* Configure DOTNET_MODIFIABLE_ASSEMBLIES=debug env variable * Fixup broken reflection
1 parent 348cc03 commit d5a9658

File tree

4 files changed

+8
-2
lines changed

4 files changed

+8
-2
lines changed

src/Components/Web.JS/dist/Release/blazor.server.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Components/Web.JS/src/Platform/BootConfig.ts

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export class BootConfigResult {
2222
export interface BootJsonData {
2323
readonly entryAssembly: string;
2424
readonly resources: ResourceGroups;
25+
/** Gets a value that determines if this boot config was produced from a non-published build (i.e. dotnet build or dotnet run) */
2526
readonly debugBuild: boolean;
2627
readonly linkerEnabled: boolean;
2728
readonly cacheBootResources: boolean;

src/Components/Web.JS/src/Platform/Mono/MonoPlatform.ts

+5
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,11 @@ function createEmscriptenModuleInstance(resourceLoader: WebAssemblyResourceLoade
428428
timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
429429
} catch { }
430430
MONO.mono_wasm_setenv("TZ", timeZone || 'UTC');
431+
if (resourceLoader.bootConfig.debugBuild) {
432+
// Configure the app to enable hot reload in Development.
433+
MONO.mono_wasm_setenv('DOTNET_MODIFIABLE_ASSEMBLIES', 'debug');
434+
}
435+
431436
const load_runtime = cwrap('mono_wasm_load_runtime', null, ['string', 'number']);
432437
// -1 enables debugging with logging disabled. 0 disables debugging entirely.
433438
load_runtime(appBinDirName, hasDebuggingEnabled() ? -1 : 0);

src/Components/WebAssembly/WebAssembly/src/Infrastructure/JSInteropMethods.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public static void ApplyHotReloadDelta(string moduleId, byte[] metadataDelta, by
6060
}
6161

6262
// Remove this once there's a runtime API to subscribe to.
63-
typeof(ComponentBase).Assembly.GetType("Microsoft.AspNetCore.Components.HotReload.HotReloadManager")!.GetMethod("DeltaApplied", BindingFlags.NonPublic | BindingFlags.Static)!.Invoke(null, null);
63+
typeof(ComponentBase).Assembly.GetType("Microsoft.AspNetCore.Components.HotReload.HotReloadManager")!.GetMethod("DeltaApplied", BindingFlags.Public | BindingFlags.Static)!.Invoke(null, null);
6464
}
6565
}
6666
}

0 commit comments

Comments
 (0)