Skip to content

Conversation

maraf
Copy link
Member

@maraf maraf commented Aug 8, 2025

The scenario that happens is:

  • Application is published in debug, meaning the HotReload package is referenced
  • Since it's publish, ILLink will remove all un-referenced assemblies
  • Running the publish output results in calling JSExport that has been ILLinked out

To mitigate it, we don't call JSExport when browser refresh script is not used

Related to dotnet/runtime#118442

@maraf maraf added this to the 10.0.1xx milestone Aug 8, 2025
@maraf maraf self-assigned this Aug 8, 2025
@maraf maraf added the Area-AspNetCore RazorSDK, BlazorWebAssemblySDK, dotnet-watch label Aug 8, 2025
Copy link
Contributor

Thanks for your PR, @@maraf.
To learn about the PR process and branching schedule of this repo, please take a look at the SDK PR Guide.

@maraf maraf marked this pull request as ready for review August 11, 2025 12:24
@Copilot Copilot AI review requested due to automatic review settings August 11, 2025 12:24
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a runtime error that occurs when a WebAssembly application is published in debug mode with HotReload packages referenced, but ILLink removes unreferenced assemblies during publishing, causing JSExport calls to fail.

  • Introduces a guard condition to prevent calling JSExport methods when the browser refresh script is not present
  • Adds early return in onRuntimeReady when HotReload is not enabled to avoid assembly export calls

@maraf
Copy link
Member Author

maraf commented Aug 11, 2025

cc @tmat

@maraf maraf merged commit 35c6ce5 into dotnet:main Aug 11, 2025
30 checks passed
@maraf maraf deleted the maraf/WasmHotReloadPublishDebug branch August 11, 2025 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-AspNetCore RazorSDK, BlazorWebAssemblySDK, dotnet-watch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants