Skip to content

Conversation

@maraf
Copy link
Member

@maraf maraf commented Jun 20, 2025

Counterpart to dotnet/aspnetcore#62417.
Generate Blazor JS initializers in way that is compatible with javascript bundlers.

@maraf maraf added this to the 10.0.0 milestone Jun 20, 2025
@maraf maraf self-assigned this Jun 20, 2025
Copilot AI review requested due to automatic review settings June 20, 2025 09:25
@maraf maraf added arch-wasm WebAssembly architecture area-Build-mono os-browser Browser variant of arch-wasm labels Jun 20, 2025
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to 'arch-wasm': @lewing
See info in area-owners.md if you want to be subscribed.

@maraf maraf requested a review from a team June 20, 2025 09:26
Copy link
Contributor

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 updates the Blazor boot JSON generation to produce bundler-friendly JS initializers.

  • Swaps libraryInitializers from a dictionary to a List<JsAsset> in the JSON model
  • Updates the builder helper to map libraryInitializers using MapJsAssets with a subfolder path

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
BootJsonData.cs Changed type of libraryInitializers from ResourceHashesByNameDictionary to List<JsAsset>
BootJsonBuilderHelper.cs Updated assignment of libraryInitializers to use MapJsAssets for bundler compatibility
Comments suppressed due to low confidence (2)

src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/BootJsonBuilderHelper.cs:259

  • There are no existing unit tests that cover the new bundler-friendly mapping of libraryInitializers. Add or update tests to verify that JS assets are correctly generated and serialized in different scenarios.
            assets.libraryInitializers = MapJsAssets(resources.libraryInitializers, subFolder: "..");

src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/BootJsonBuilderHelper.cs:259

  • Changing libraryInitializers from a dictionary to a list alters lookup complexity from O(1) to O(n). Verify that consumers of the generated JSON do not rely on dictionary-style key lookups or consider retaining an in-memory dictionary for efficient access.
            assets.libraryInitializers = MapJsAssets(resources.libraryInitializers, subFolder: "..");

@maraf maraf merged commit 8745035 into dotnet:main Jun 20, 2025
26 of 31 checks passed
@maraf
Copy link
Member Author

maraf commented Jun 20, 2025

/backport to release/10.0-preview6

@github-actions
Copy link
Contributor

Started backporting to release/10.0-preview6: https://github.com/dotnet/runtime/actions/runs/15781004801

@maraf maraf deleted the BrowserBundlerFriendlyBlazorInitializers branch June 23, 2025 12:24
@github-actions github-actions bot locked and limited conversation to collaborators Jul 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

arch-wasm WebAssembly architecture area-Build-mono os-browser Browser variant of arch-wasm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants