[release/9.0.1xx] [Blazor] Fix hot reload for components with collocated JS files #45120
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport of #43199 to release/9.0.1xx
Fix hot reload for components with collocated JS files
Fixes an issue where if any components in a Blazor project have collocated JS, CSS hot reload fails.
Description
"Collocated JS" refers to JavaScript files that end with
.razor.js
and are associated with a Razor component. These files participate in the hot reload experience, so edits will apply to already-running Blazor apps.As part of applying hot reload updates to collocate JS files, the build pipeline attempts to match up
.razor.js
files with their corresponding Razor components. However, changes to build logic in .NET 9 caused the discovery of Razor components to get skipped in hot reload scenarios, causing a build error indicating that collocated JS files couldn't be correctly mapped to Razor components.The fix is to execute the missing stages of the build pipeline when a hot reload edit occurs.
Fixes dotnet/aspnetcore#57599
Customer Impact
High. Collocated JS is a very common pattern found in Blazor projects, so this bug is expected to impact a large portion of developers. We've already seen feedback from multiple customers that this is an issue. There is no known workaround.
Regression?
Regressed from .NET 9 preview 6
Risk
The change is straightforward and only impacts hot reload scenarios.
Verification
Packaging changes reviewed?