Skip to content
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

Put only hard fingerprinted files into import map during publish #47515

Merged
merged 5 commits into from
Mar 14, 2025

Conversation

maraf
Copy link
Member

@maraf maraf commented Mar 12, 2025

The WriteImportMapToHtml feature is meant for Wasm/Blazor standalone scenarios. During development, those apps are serve through DevServer which integrates StaticWebAssets runtime features and provide a correct routing for soft fingerprinted files. In production, StaticWebAssets runtime features are not available, as those apps are typically hosted as static sites. That means we should put only hard fingerprinted assets into import map.

@maraf maraf added the Area-AspNetCore RazorSDK, BlazorWebAssemblySDK, dotnet-watch label Mar 12, 2025
@maraf maraf self-assigned this Mar 12, 2025
@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged Request triage from a team member label Mar 12, 2025
@maraf maraf added this to the 10.0.1xx milestone Mar 13, 2025
@maraf maraf removed the untriaged Request triage from a team member label Mar 13, 2025
@maraf maraf marked this pull request as ready for review March 13, 2025 12:09
@Copilot Copilot bot review requested due to automatic review settings March 13, 2025 12:09
@maraf maraf requested a review from a team as a code owner March 13, 2025 12:09
@maraf maraf requested review from ilonatommy and a team March 13, 2025 12:09

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 asset fingerprinting behavior during publish so that only hard fingerprinted files are included in the import map for static sites.

  • Added new properties (Assets, IncludeOnlyHardFingerprintedModules) and refactored the fingerprint replacement logic.
  • Updated resource creation to check asset metadata for hard fingerprinting and modified related tests to validate both build and publish scenarios.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

File Description
src/StaticWebAssetsSdk/Tasks/WriteImportMapToHtml.cs Refactored fingerprinting logic and resource creation to conditionally include only hard fingerprinted assets.
test/Microsoft.NET.Sdk.Razor.Tests/StaticWebAssetsFingerprintingTest.cs Updated tests with additional parameters and helper methods to cover the new fingerprinting behavior.
Comments suppressed due to low confidence (2)

src/StaticWebAssetsSdk/Tasks/WriteImportMapToHtml.cs:176

  • The expression 'integrity ??= [];' uses invalid syntax for initializing a dictionary. Replace it with 'integrity ??= new Dictionary<string, string>();'.
integrity ??= [];

src/StaticWebAssetsSdk/Tasks/WriteImportMapToHtml.cs:184

  • The expression 'imports ??= [];' is not valid for dictionary initialization. Use 'imports ??= new Dictionary<string, string>();' instead.
imports ??= [];
@maraf maraf enabled auto-merge (squash) March 14, 2025 12:31
@maraf maraf merged commit 5f50397 into dotnet:main Mar 14, 2025
39 checks passed
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