Faster preview on no change, future hot reload#192
Conversation
|
I will merge this in few days if nobody else wants to test this manually. |
versile2
left a comment
There was a problem hiding this comment.
I have loaded and ran the sample, it ran without issue. I did not look at deep detail of the code as it's so far from dev due to other updates. If you would like me to let me know and I should have time early next week. That being said it seems to work great, recognizes when code has changed etc. One thing I would note is that only the "hot reload" should use that logic, I should be able to click "Play" and cause a relaod so I can handle or test stuff that happens only onafterrender oninit.
|



Fixes #198
Previously, every compilation triggered a full iframe navigation, even when the code hadn’t changed.
Now, if there’s no code change, the preview updates instantly:

(you need to run it with no debugger).
This code also gives some future improvements, once web workers are shipped: dotnet/aspnetcore#65037
CompilationServicecould run on a worker thread. The pipeline would become:Editor onChange (debounced ~300ms)
→ Worker thread: CompilationService.CompileAsync()
→ postMessage(dllBytes) back to main thread
→ updateUserComponentsDll + hotReloadIframe
→ iframe: AssemblyLoadContext swap
→ DynamicComponent re-renders
Everything from updateUserComponentsDll downward is already in place. The only missing piece is moving compilation
off-thread.
Rough prototype shape