-
Notifications
You must be signed in to change notification settings - Fork 10.3k
[Blazor] Generate Link headers based on StaticWebAssets manifest properties #61166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/Components/Endpoints/src/Rendering/EndpointHtmlRenderer.Streaming.cs
Outdated
Show resolved
Hide resolved
src/Components/Endpoints/src/Rendering/EndpointHtmlRenderer.Streaming.cs
Outdated
Show resolved
Hide resolved
src/Components/Endpoints/src/Rendering/EndpointHtmlRenderer.Streaming.cs
Show resolved
Hide resolved
src/Components/Endpoints/src/Rendering/EndpointHtmlRenderer.Streaming.cs
Show resolved
Hide resolved
There was a problem hiding this 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 adds support for generating Link headers based on StaticWebAssets manifest properties for WebAssembly preloading. Key changes include:
- Propagation and handling of new preload-related properties in the resource collection resolver.
- Extension of endpoint rendering logic to append preload headers when using WebAssembly.
- Introduction of a new ResourcePreloadCollection class for grouping and ordering preload header values.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
src/Shared/Components/ResourceCollectionResolver.cs | Added new string variables and updated AddResource to include preload attributes. |
src/Components/Endpoints/test/EndpointHtmlRendererTest.cs | Added tests to verify correct generation and ordering of preload Link headers. |
src/Components/Endpoints/src/Rendering/EndpointHtmlRenderer.Streaming.cs | Updated rendering logic to append WebAssembly preload headers conditionally. |
src/Components/Endpoints/src/Builder/ResourcePreloadCollection.cs | Introduced new logic to build and order preload Link headers from resource assets. |
src/Components/Endpoints/src/Builder/ResourceCollectionConvention.cs | Updated endpoint metadata conventions to include ResourcePreloadCollection. |
src/Components/Endpoints/src/Builder/ResourcePreloadCollection.cs
Outdated
Show resolved
Hide resolved
src/Components/Endpoints/src/Builder/ResourcePreloadCollection.cs
Outdated
Show resolved
Hide resolved
src/Components/Endpoints/src/Builder/ResourcePreloadCollection.cs
Outdated
Show resolved
Hide resolved
|
||
foreach (var group in headers.GroupBy(h => h.Group)) | ||
{ | ||
_storage[group.Key ?? string.Empty] = group.OrderBy(h => h.Order).Select(h => h.Value).ToArray(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the order here "override" the fetch priority?
Also, rather than starting with a list, could we start already with a Dictionary<string, List> or something like that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea is that within the same fetch priority, you can define the order, as throttling may apply
src/Components/Endpoints/src/Builder/ResourcePreloadCollection.cs
Outdated
Show resolved
Hide resolved
src/Components/Endpoints/src/Builder/ResourcePreloadCollection.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comments but it looks good
Use properties generated on StaticWebAsset endpoints to generate Link headers.
The endpoint selection will be part of WebAssembly SDK.
The StaticWebAsset endpoint properties are following
preloadgroup
is used to identify assets to preload during WebAssembly component pre-renderingpreloadrel
is translated torel
attribute and defines relationship (preload
ormodulepreload
are values that will be used for runtime assets)preloadas
is translated toas
attribute and specifies the type of content being loaded (script
orfetch
are values that will be used for runtime assets)preloadpriority
is translated tofetchpriority
attribute, is optional, and specifies the prioritypreloadcrossorigin
is translated tocrossorigin
attribute (anonymous
is the value that will be used for runtime assets)integrity
is translated tointegrity
attribute and specifies the integrity of the assetpreloadorder
is used to sort headers based on priorityExample headers
Contributes #58875