Skip to content

Fix trimming issues of BlazorUI in client server projects (#13907) - #13964

Merged
msynk merged 3 commits into
developfrom
msynk/13907-blazorui-trimming-issues-in-client-server-projects
Oct 19, 2026
Merged

msynk merged 3 commits into
developfrom
msynk/13907-blazorui-trimming-issues-in-client-server-projects

Conversation

@msynk

@msynk msynk commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

closes #13907

Summary by CodeRabbit

  • New Features
    • Published hosted Blazor WebAssembly apps now receive service-worker manifests that reflect the files and hashes actually served after trimming. Related service-worker versions are updated to match.
    • Standalone WebAssembly app manifests remain unchanged by the hosted-app rewrite.
  • Bug Fixes
    • Prevented removed or trimmed assets from being incorrectly listed in hosted-app service-worker manifests.
  • Documentation
    • Clarified how service-worker manifests are handled for hosted and standalone apps, including warnings for manifests or scripts that cannot be updated.

@msynk
msynk requested a review from yasmoradi as a code owner October 19, 2026 09:17
…into msynk/13907-blazorui-trimming-issues-in-client-server-projects
@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 712cb698-f90d-41ab-9165-2da2d5ad7a81

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f3cc9af0-1d29-488c-9489-eb3bc7ca45ee
📥 Commits

Reviewing files that changed from the base of the PR and between ba3ee2b and cc367a5.

📒 Files selected for processing: 21
  • src/BlazorUI/Bit.BlazorUI.Build/ServiceWorkerManifest.cs
  • src/BlazorUI/Bit.BlazorUI.Build/ServiceWorkerManifestUpdate.cs
  • src/BlazorUI/Bit.BlazorUI.Build/UpdateBitBlazorUIServiceWorker.cs
  • src/BlazorUI/Bit.BlazorUI/buildTransitive/Bit.BlazorUI.Endpoints.targets
  • src/BlazorUI/Bit.BlazorUI/buildTransitive/Bit.BlazorUI.targets
  • src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/TrimmingPage.razor
  • src/BlazorUI/Tests/Bit.BlazorUI.Tests.Trimming.Hosted.Client/Bit.BlazorUI.Tests.Trimming.Hosted.Client.csproj
  • src/BlazorUI/Tests/Bit.BlazorUI.Tests.Trimming.Hosted.Client/Main.razor
  • src/BlazorUI/Tests/Bit.BlazorUI.Tests.Trimming.Hosted.Client/Program.cs
  • src/BlazorUI/Tests/Bit.BlazorUI.Tests.Trimming.Hosted.Client/wwwroot/index.html
  • src/BlazorUI/Tests/Bit.BlazorUI.Tests.Trimming.Hosted.Client/wwwroot/service-worker.js
  • src/BlazorUI/Tests/Bit.BlazorUI.Tests.Trimming.Hosted.Client/wwwroot/service-worker.published.js
  • src/BlazorUI/Tests/Bit.BlazorUI.Tests.Trimming.Hosted/Bit.BlazorUI.Tests.Trimming.Hosted.csproj
  • src/BlazorUI/Tests/Bit.BlazorUI.Tests.Trimming.Hosted/Program.cs
  • src/BlazorUI/Tests/Bit.BlazorUI.Tests.Trimming/Bit.BlazorUI.Tests.Trimming.csproj
  • src/BlazorUI/Tests/Bit.BlazorUI.Tests.Trimming/HostedAppTrimmingTests.cs
  • src/BlazorUI/Tests/Bit.BlazorUI.Tests.Trimming/Infrastructure/PublishResult.cs
  • src/BlazorUI/Tests/Bit.BlazorUI.Tests.Trimming/Infrastructure/Publisher.cs
  • src/BlazorUI/Tests/Bit.BlazorUI.Tests.Trimming/PackageTrimmingTests.cs
  • src/BlazorUI/Tests/Bit.BlazorUI.Tests.Trimming/README.md
  • src/BlazorUI/Tests/Bit.BlazorUI.Tests/Utils/Trimming/BitServiceWorkerManifestTests.cs

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

Walkthrough

The publish pipeline now rewrites Blazor Web App service-worker manifests after asset trimming, updates matching service-worker script versions, and replaces stale static assets. New tests cover hosted and standalone publish scenarios.

Changes

Service-worker manifest trimming

Layer / File(s) Summary
Manifest rewrite rules
src/BlazorUI/Bit.BlazorUI.Build/ServiceWorkerManifest*.cs, src/BlazorUI/Tests/Bit.BlazorUI.Tests/Utils/Trimming/BitServiceWorkerManifestTests.cs
Manifest updates remove dropped URLs, apply changed hashes to retained assets, calculate a version from retained URL/hash pairs, and normalize asset URLs. Unit tests cover supported manifest shapes, text preservation, version changes, and URL matching.
Publish-time rewrite and asset replacement
src/BlazorUI/Bit.BlazorUI.Build/UpdateBitBlazorUIServiceWorker.cs, src/BlazorUI/Bit.BlazorUI/buildTransitive/*.targets
The MSBuild task updates manifests and matching scripts after trimming. Build targets replace stale assets with rewritten candidates and define endpoints where applicable.
Hosted publish scenarios and validation
src/BlazorUI/Tests/Bit.BlazorUI.Tests.Trimming.Hosted*/*, src/BlazorUI/Tests/Bit.BlazorUI.Tests.Trimming/{HostedAppTrimmingTests.cs,Infrastructure/*,PackageTrimmingTests.cs,README.md}, src/BlazorUI/Demo/Client/.../TrimmingPage.razor
Hosted and standalone publish tests check manifest entries and hashes, compressed copies, and endpoint metadata. The trimming documentation describes the manifest rewrite and related warnings.

Priority: ➖ Normal

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant PublishTargets
  participant UpdateTask
  participant ManifestUtility
  participant StaticWebAssets
  PublishTargets->>UpdateTask: pass current, dropped, and trimmed assets
  UpdateTask->>ManifestUtility: remove dropped URLs and update hashes
  ManifestUtility-->>UpdateTask: return rewritten manifest and version
  UpdateTask->>StaticWebAssets: write changed manifest and script candidates
  UpdateTask-->>PublishTargets: return candidate and stale assets
  PublishTargets->>StaticWebAssets: replace stale assets and define rewritten endpoints
Loading
Merge Risk: ⚪ Minimal · up to cc367

The change rewrites service-worker manifests after asset trimming and adds tests for hosted and standalone publishes. No concrete merge-blocking issue was identified.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 65.22% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 46 functions across 12 files. (9 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly identifies the main change: fixing BlazorUI asset-trimming issues in client-server projects. It is related to the service-worker manifest rewrite implemented by the pull request.
Linked Issues check Passed Issue #13907 requires a Blazor Web App publish to update its client service-worker manifest after server-side trimming. UpdateBitBlazorUIServiceWorker and the MSBuild targets perform this update. `S…
Out of Scope Changes check Passed The implementation, MSBuild integration, documentation, hosted test projects, manifest tests, endpoint checks, and compression checks support issue #13907. The tests verify the published files, hashes…
Full details: Linked Issues check

Explanation

Issue #13907 requires a Blazor Web App publish to update its client service-worker manifest after server-side trimming. UpdateBitBlazorUIServiceWorker and the MSBuild targets perform this update. ServiceWorkerManifest removes URLs for omitted assets, applies hashes for retained trimmed assets, recalculates the manifest version, and updates the service-worker version marker. The hosted trimming tests verify dropped entries, replacement hashes, served-file coverage, and standalone behavior. The standalone client is not rewritten when its SDK-generated manifest already reflects trimmed files.

Full details: Out of Scope Changes check

Explanation

The implementation, MSBuild integration, documentation, hosted test projects, manifest tests, endpoint checks, and compression checks support issue #13907. The tests verify the published files, hashes, service-worker entries, version updates, and endpoint metadata affected by the trimming rewrite. No unrelated change is demonstrated.

Full details: Docstring Coverage

Explanation

Docstring coverage is 65.22% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 46 functions across 12 files. (9 skipped: 9 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit checks the asset list,
And trims the URLs that should not persist.
New hashes settle into place,
A fresh version marks their case.
The service worker hops along,
With matching files in its song.

Comment @coderabbitai help to get the list of available commands.

@msynk
msynk merged commit 24c2ba2 into develop Oct 19, 2026
8 checks passed
@msynk
msynk deleted the msynk/13907-blazorui-trimming-issues-in-client-server-projects branch October 19, 2026 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BlazorUI's trimming leaves a Blazor Web App's service worker manifest describing the full bundles

1 participant