From 621b56fcbc033004a98a88bbeb60f85d62067c21 Mon Sep 17 00:00:00 2001 From: Javier Calvarro Nelson Date: Wed, 26 Mar 2025 20:02:03 +0100 Subject: [PATCH 1/5] Fingerprint JS modules --- .../Targets/Microsoft.NET.Sdk.StaticWebAssets.JSModules.targets | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/StaticWebAssetsSdk/Targets/Microsoft.NET.Sdk.StaticWebAssets.JSModules.targets b/src/StaticWebAssetsSdk/Targets/Microsoft.NET.Sdk.StaticWebAssets.JSModules.targets index 7bb59c7aa940..118e4f0cb420 100644 --- a/src/StaticWebAssetsSdk/Targets/Microsoft.NET.Sdk.StaticWebAssets.JSModules.targets +++ b/src/StaticWebAssetsSdk/Targets/Microsoft.NET.Sdk.StaticWebAssets.JSModules.targets @@ -264,6 +264,7 @@ Copyright (c) .NET Foundation. All rights reserved. AssetMode="CurrentProject" AssetRole="Primary" AssetMergeSource="$(StaticWebAssetMergeTarget)" + FingerprintCandidates="$(StaticWebAssetsFingerprintContent)" AssetTraitName="JSModule" AssetTraitValue="JSModuleManifest" > @@ -380,6 +381,7 @@ Copyright (c) .NET Foundation. All rights reserved. AssetMergeSource="$(StaticWebAssetMergeTarget)" AssetTraitName="JSModule" AssetTraitValue="JSModuleManifest" + FingerprintCandidates="$(StaticWebAssetsFingerprintContent)" > From 4331462b83bea07b465eeb18bd5ca6135516e631 Mon Sep 17 00:00:00 2001 From: Javier Calvarro Nelson Date: Wed, 26 Mar 2025 20:57:47 +0100 Subject: [PATCH 2/5] Fix regex --- .../Microsoft.NET.Sdk.StaticWebAssets.JSModules.targets | 6 ++++++ src/StaticWebAssetsSdk/Tasks/JSModules/ApplyJsModules.cs | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/StaticWebAssetsSdk/Targets/Microsoft.NET.Sdk.StaticWebAssets.JSModules.targets b/src/StaticWebAssetsSdk/Targets/Microsoft.NET.Sdk.StaticWebAssets.JSModules.targets index 118e4f0cb420..a5822c836a97 100644 --- a/src/StaticWebAssetsSdk/Targets/Microsoft.NET.Sdk.StaticWebAssets.JSModules.targets +++ b/src/StaticWebAssetsSdk/Targets/Microsoft.NET.Sdk.StaticWebAssets.JSModules.targets @@ -265,6 +265,7 @@ Copyright (c) .NET Foundation. All rights reserved. AssetRole="Primary" AssetMergeSource="$(StaticWebAssetMergeTarget)" FingerprintCandidates="$(StaticWebAssetsFingerprintContent)" + FingerprintPatterns="@(StaticWebAssetFingerprintPattern)" AssetTraitName="JSModule" AssetTraitValue="JSModuleManifest" > @@ -382,6 +383,7 @@ Copyright (c) .NET Foundation. All rights reserved. AssetTraitName="JSModule" AssetTraitValue="JSModuleManifest" FingerprintCandidates="$(StaticWebAssetsFingerprintContent)" + FingerprintPatterns="@(StaticWebAssetFingerprintPattern)" > @@ -430,6 +432,8 @@ Copyright (c) .NET Foundation. All rights reserved. SourceType="Discovered" BasePath="$(StaticWebAssetBasePath)" AssetMergeSource="$(StaticWebAssetMergeTarget)" + FingerprintCandidates="$(StaticWebAssetsFingerprintContent)" + FingerprintPatterns="@(StaticWebAssetFingerprintPattern)" CacheManifestPath="$(_ResolveJSModuleStaticWebAssetsRazorCachePath)"> @@ -443,6 +447,8 @@ Copyright (c) .NET Foundation. All rights reserved. SourceType="Discovered" BasePath="$(StaticWebAssetBasePath)" AssetMergeSource="$(StaticWebAssetMergeTarget)" + FingerprintCandidates="$(StaticWebAssetsFingerprintContent)" + FingerprintPatterns="@(StaticWebAssetFingerprintPattern)" CacheManifestPath="$(_ResolveJSModuleStaticWebAssetsCshtmlCachePath)"> diff --git a/src/StaticWebAssetsSdk/Tasks/JSModules/ApplyJsModules.cs b/src/StaticWebAssetsSdk/Tasks/JSModules/ApplyJsModules.cs index 1a844a31d3d0..cfa55f761c5a 100644 --- a/src/StaticWebAssetsSdk/Tasks/JSModules/ApplyJsModules.cs +++ b/src/StaticWebAssetsSdk/Tasks/JSModules/ApplyJsModules.cs @@ -39,7 +39,7 @@ public override bool Execute() unmatchedJsModules, jsModulesByRazorItem, "RazorComponent", - "(.*)\\.razor\\.js$", + "(.*?)(?:#\\[.*?\\](?:\\?|!)?)?(\\.razor\\.js)$", "$1.razor"); } @@ -52,7 +52,7 @@ public override bool Execute() unmatchedJsModules, jsModulesByRazorItem, "View", - "(.*)\\.cshtml\\.js$", + "(.*?)(?:#\\[.*?\\](?:\\?|!)?)?(\\.cshtml\\.js)$", "$1.cshtml"); } From a7bb64c63eaea96afcbde1f019b7cad326de8cbe Mon Sep 17 00:00:00 2001 From: Javier Calvarro Nelson Date: Thu, 27 Mar 2025 10:36:45 +0100 Subject: [PATCH 3/5] Update baselines --- ...undleToTheRightLocation.Publish.files.json | 10 +- ...RightLocation.Publish.staticwebassets.json | 367 +++++++++++++++--- 2 files changed, 327 insertions(+), 50 deletions(-) diff --git a/test/Microsoft.NET.Sdk.Razor.Tests/StaticWebAssetsBaselines/Publish_PublishesJsModuleBundleBundleToTheRightLocation.Publish.files.json b/test/Microsoft.NET.Sdk.Razor.Tests/StaticWebAssetsBaselines/Publish_PublishesJsModuleBundleBundleToTheRightLocation.Publish.files.json index 2e8855bb22d7..7e0b1e229e08 100644 --- a/test/Microsoft.NET.Sdk.Razor.Tests/StaticWebAssetsBaselines/Publish_PublishesJsModuleBundleBundleToTheRightLocation.Publish.files.json +++ b/test/Microsoft.NET.Sdk.Razor.Tests/StaticWebAssetsBaselines/Publish_PublishesJsModuleBundleBundleToTheRightLocation.Publish.files.json @@ -17,21 +17,21 @@ "${ProjectPath}\\obj\\Debug\\${Tfm}\\compressed\\_content\\ComponentApp\\ComponentApp#[.{fingerprint=__fingerprint__}]!.bundle.scp.css.gz", "${ProjectPath}\\obj\\Debug\\${Tfm}\\compressed\\_content\\ComponentApp\\ComponentApp#[.{fingerprint=__fingerprint__}]?.styles.css.gz", "${ProjectPath}\\obj\\Debug\\${Tfm}\\compressed\\publish\\_content\\ComponentApp\\ComponentApp#[.{fingerprint=__fingerprint__}]!.bundle.scp.css.br", + "${ProjectPath}\\obj\\Debug\\${Tfm}\\compressed\\publish\\_content\\ComponentApp\\ComponentApp#[.{fingerprint=__fingerprint__}]?.modules.json.br", + "${ProjectPath}\\obj\\Debug\\${Tfm}\\compressed\\publish\\_content\\ComponentApp\\ComponentApp#[.{fingerprint=__fingerprint__}]?.modules.json.gz", "${ProjectPath}\\obj\\Debug\\${Tfm}\\compressed\\publish\\_content\\ComponentApp\\ComponentApp#[.{fingerprint=__fingerprint__}]?.styles.css.br", - "${ProjectPath}\\obj\\Debug\\${Tfm}\\compressed\\publish\\_content\\ComponentApp\\ComponentApp.modules.json.br", - "${ProjectPath}\\obj\\Debug\\${Tfm}\\compressed\\publish\\_content\\ComponentApp\\ComponentApp.modules.json.gz", "${ProjectPath}\\obj\\Debug\\${Tfm}\\jsmodules\\jsmodules.publish.manifest.json", "${ProjectPath}\\obj\\Debug\\${Tfm}\\scopedcss\\bundle\\ComponentApp.styles.css", "${ProjectPath}\\obj\\Debug\\${Tfm}\\scopedcss\\projectbundle\\ComponentApp.bundle.scp.css", "${OutputPath}\\wwwroot\\ComponentApp#[.{fingerprint=__fingerprint__}]!.lib.module.js.br", "${OutputPath}\\wwwroot\\ComponentApp#[.{fingerprint=__fingerprint__}]!.lib.module.js.gz", + "${OutputPath}\\wwwroot\\ComponentApp#[.{fingerprint=__fingerprint__}]?.modules.json.br", + "${OutputPath}\\wwwroot\\ComponentApp#[.{fingerprint=__fingerprint__}]?.modules.json.gz", "${OutputPath}\\wwwroot\\ComponentApp#[.{fingerprint=__fingerprint__}]?.styles.css.br", "${OutputPath}\\wwwroot\\ComponentApp#[.{fingerprint=__fingerprint__}]?.styles.css.gz", "${OutputPath}\\wwwroot\\ComponentApp#[.{fingerprint}]!.lib.module.js", + "${OutputPath}\\wwwroot\\ComponentApp#[.{fingerprint}]?.modules.json", "${OutputPath}\\wwwroot\\ComponentApp#[.{fingerprint}]?.styles.css", - "${OutputPath}\\wwwroot\\ComponentApp.modules.json", - "${OutputPath}\\wwwroot\\ComponentApp.modules.json.br", - "${OutputPath}\\wwwroot\\ComponentApp.modules.json.gz", "${OutputPath}\\wwwroot\\_framework\\blazor.server.js", "${OutputPath}\\wwwroot\\_framework\\blazor.server.js.br", "${OutputPath}\\wwwroot\\_framework\\blazor.server.js.gz", diff --git a/test/Microsoft.NET.Sdk.Razor.Tests/StaticWebAssetsBaselines/Publish_PublishesJsModuleBundleBundleToTheRightLocation.Publish.staticwebassets.json b/test/Microsoft.NET.Sdk.Razor.Tests/StaticWebAssetsBaselines/Publish_PublishesJsModuleBundleBundleToTheRightLocation.Publish.staticwebassets.json index b525c9f8a244..005fcf44fbea 100644 --- a/test/Microsoft.NET.Sdk.Razor.Tests/StaticWebAssetsBaselines/Publish_PublishesJsModuleBundleBundleToTheRightLocation.Publish.staticwebassets.json +++ b/test/Microsoft.NET.Sdk.Razor.Tests/StaticWebAssetsBaselines/Publish_PublishesJsModuleBundleBundleToTheRightLocation.Publish.staticwebassets.json @@ -178,35 +178,35 @@ "LastWriteTime": "0001-01-01T00:00:00+00:00" }, { - "Identity": "${ProjectPath}\\obj\\Debug\\${Tfm}\\compressed\\publish\\_content\\ComponentApp\\ComponentApp#[.{fingerprint=__fingerprint__}]?.styles.css.br", + "Identity": "${ProjectPath}\\obj\\Debug\\${Tfm}\\compressed\\publish\\_content\\ComponentApp\\ComponentApp#[.{fingerprint=__fingerprint__}]?.modules.json.br", "SourceId": "ComponentApp", "SourceType": "Computed", "ContentRoot": "${ProjectPath}\\obj\\Debug\\${Tfm}\\compressed\\publish\\", "BasePath": "_content/ComponentApp", - "RelativePath": "ComponentApp#[.{fingerprint=__fingerprint__}]?.styles.css.br", - "AssetKind": "All", + "RelativePath": "ComponentApp#[.{fingerprint=__fingerprint__}]?.modules.json.br", + "AssetKind": "Publish", "AssetMode": "CurrentProject", "AssetRole": "Alternative", "AssetMergeBehavior": "", "AssetMergeSource": "", - "RelatedAsset": "${ProjectPath}\\obj\\Debug\\${Tfm}\\scopedcss\\bundle\\ComponentApp.styles.css", + "RelatedAsset": "${ProjectPath}\\obj\\Debug\\${Tfm}\\jsmodules\\jsmodules.publish.manifest.json", "AssetTraitName": "Content-Encoding", "AssetTraitValue": "br", "Fingerprint": "__fingerprint__", "Integrity": "__integrity__", "CopyToOutputDirectory": "Never", "CopyToPublishDirectory": "PreserveNewest", - "OriginalItemSpec": "${ProjectPath}\\obj\\Debug\\${Tfm}\\scopedcss\\bundle\\_content\\ComponentApp\\ComponentApp#[.{fingerprint=__fingerprint__}]?.styles.css.br", + "OriginalItemSpec": "${ProjectPath}\\obj\\Debug\\${Tfm}\\jsmodules\\_content\\ComponentApp\\ComponentApp#[.{fingerprint=__fingerprint__}]?.modules.json.br", "FileLength": -1, "LastWriteTime": "0001-01-01T00:00:00+00:00" }, { - "Identity": "${ProjectPath}\\obj\\Debug\\${Tfm}\\compressed\\publish\\_content\\ComponentApp\\ComponentApp.modules.json.br", + "Identity": "${ProjectPath}\\obj\\Debug\\${Tfm}\\compressed\\publish\\_content\\ComponentApp\\ComponentApp#[.{fingerprint=__fingerprint__}]?.modules.json.gz", "SourceId": "ComponentApp", "SourceType": "Computed", "ContentRoot": "${ProjectPath}\\obj\\Debug\\${Tfm}\\compressed\\publish\\", "BasePath": "_content/ComponentApp", - "RelativePath": "ComponentApp.modules.json.br", + "RelativePath": "ComponentApp#[.{fingerprint=__fingerprint__}]?.modules.json.gz", "AssetKind": "Publish", "AssetMode": "CurrentProject", "AssetRole": "Alternative", @@ -214,35 +214,35 @@ "AssetMergeSource": "", "RelatedAsset": "${ProjectPath}\\obj\\Debug\\${Tfm}\\jsmodules\\jsmodules.publish.manifest.json", "AssetTraitName": "Content-Encoding", - "AssetTraitValue": "br", + "AssetTraitValue": "gzip", "Fingerprint": "__fingerprint__", "Integrity": "__integrity__", "CopyToOutputDirectory": "Never", "CopyToPublishDirectory": "PreserveNewest", - "OriginalItemSpec": "${ProjectPath}\\obj\\Debug\\${Tfm}\\jsmodules\\_content\\ComponentApp\\ComponentApp.modules.json.br", + "OriginalItemSpec": "${ProjectPath}\\obj\\Debug\\${Tfm}\\jsmodules\\_content\\ComponentApp\\ComponentApp#[.{fingerprint=__fingerprint__}]?.modules.json.gz", "FileLength": -1, "LastWriteTime": "0001-01-01T00:00:00+00:00" }, { - "Identity": "${ProjectPath}\\obj\\Debug\\${Tfm}\\compressed\\publish\\_content\\ComponentApp\\ComponentApp.modules.json.gz", + "Identity": "${ProjectPath}\\obj\\Debug\\${Tfm}\\compressed\\publish\\_content\\ComponentApp\\ComponentApp#[.{fingerprint=__fingerprint__}]?.styles.css.br", "SourceId": "ComponentApp", "SourceType": "Computed", "ContentRoot": "${ProjectPath}\\obj\\Debug\\${Tfm}\\compressed\\publish\\", "BasePath": "_content/ComponentApp", - "RelativePath": "ComponentApp.modules.json.gz", - "AssetKind": "Publish", + "RelativePath": "ComponentApp#[.{fingerprint=__fingerprint__}]?.styles.css.br", + "AssetKind": "All", "AssetMode": "CurrentProject", "AssetRole": "Alternative", "AssetMergeBehavior": "", "AssetMergeSource": "", - "RelatedAsset": "${ProjectPath}\\obj\\Debug\\${Tfm}\\jsmodules\\jsmodules.publish.manifest.json", + "RelatedAsset": "${ProjectPath}\\obj\\Debug\\${Tfm}\\scopedcss\\bundle\\ComponentApp.styles.css", "AssetTraitName": "Content-Encoding", - "AssetTraitValue": "gzip", + "AssetTraitValue": "br", "Fingerprint": "__fingerprint__", "Integrity": "__integrity__", "CopyToOutputDirectory": "Never", "CopyToPublishDirectory": "PreserveNewest", - "OriginalItemSpec": "${ProjectPath}\\obj\\Debug\\${Tfm}\\jsmodules\\_content\\ComponentApp\\ComponentApp.modules.json.gz", + "OriginalItemSpec": "${ProjectPath}\\obj\\Debug\\${Tfm}\\scopedcss\\bundle\\_content\\ComponentApp\\ComponentApp#[.{fingerprint=__fingerprint__}]?.styles.css.br", "FileLength": -1, "LastWriteTime": "0001-01-01T00:00:00+00:00" }, @@ -298,7 +298,7 @@ "SourceType": "Computed", "ContentRoot": "${ProjectPath}\\obj\\Debug\\${Tfm}\\jsmodules\\", "BasePath": "_content/ComponentApp", - "RelativePath": "ComponentApp.modules.json", + "RelativePath": "ComponentApp#[.{fingerprint}]?.modules.json", "AssetKind": "Publish", "AssetMode": "CurrentProject", "AssetRole": "Primary", @@ -1977,8 +1977,8 @@ ] }, { - "Route": "ComponentApp.styles.css.br", - "AssetFile": "${ProjectPath}\\obj\\Debug\\${Tfm}\\compressed\\publish\\_content\\ComponentApp\\ComponentApp#[.{fingerprint=__fingerprint__}]?.styles.css.br", + "Route": "ComponentApp.modules.json.br", + "AssetFile": "${ProjectPath}\\obj\\Debug\\${Tfm}\\compressed\\publish\\_content\\ComponentApp\\ComponentApp#[.{fingerprint=__fingerprint__}]?.modules.json.br", "Selectors": [], "ResponseHeaders": [ { @@ -1999,7 +1999,7 @@ }, { "Name": "Content-Type", - "Value": "text/css" + "Value": "application/json" }, { "Name": "ETag", @@ -2022,8 +2022,8 @@ ] }, { - "Route": "ComponentApp.__fingerprint__.styles.css.br", - "AssetFile": "${ProjectPath}\\obj\\Debug\\${Tfm}\\compressed\\publish\\_content\\ComponentApp\\ComponentApp#[.{fingerprint=__fingerprint__}]?.styles.css.br", + "Route": "ComponentApp.eq4eem9pbl.modules.json.br", + "AssetFile": "${ProjectPath}\\obj\\Debug\\${Tfm}\\compressed\\publish\\_content\\ComponentApp\\ComponentApp#[.{fingerprint=__fingerprint__}]?.modules.json.br", "Selectors": [], "ResponseHeaders": [ { @@ -2044,7 +2044,7 @@ }, { "Name": "Content-Type", - "Value": "text/css" + "Value": "application/json" }, { "Name": "ETag", @@ -2070,13 +2070,13 @@ }, { "Name": "label", - "Value": "ComponentApp.styles.css.br" + "Value": "ComponentApp.modules.json.br" } ] }, { - "Route": "ComponentApp.styles.css", - "AssetFile": "${ProjectPath}\\obj\\Debug\\${Tfm}\\compressed\\publish\\_content\\ComponentApp\\ComponentApp#[.{fingerprint=__fingerprint__}]?.styles.css.br", + "Route": "ComponentApp.modules.json", + "AssetFile": "${ProjectPath}\\obj\\Debug\\${Tfm}\\compressed\\publish\\_content\\ComponentApp\\ComponentApp#[.{fingerprint=__fingerprint__}]?.modules.json.br", "Selectors": [ { "Name": "Content-Encoding", @@ -2103,7 +2103,7 @@ }, { "Name": "Content-Type", - "Value": "text/css" + "Value": "application/json" }, { "Name": "ETag", @@ -2130,8 +2130,8 @@ ] }, { - "Route": "ComponentApp.__fingerprint__.styles.css", - "AssetFile": "${ProjectPath}\\obj\\Debug\\${Tfm}\\compressed\\publish\\_content\\ComponentApp\\ComponentApp#[.{fingerprint=__fingerprint__}]?.styles.css.br", + "Route": "ComponentApp.eq4eem9pbl.modules.json", + "AssetFile": "${ProjectPath}\\obj\\Debug\\${Tfm}\\compressed\\publish\\_content\\ComponentApp\\ComponentApp#[.{fingerprint=__fingerprint__}]?.modules.json.br", "Selectors": [ { "Name": "Content-Encoding", @@ -2158,7 +2158,7 @@ }, { "Name": "Content-Type", - "Value": "text/css" + "Value": "application/json" }, { "Name": "ETag", @@ -2188,13 +2188,13 @@ }, { "Name": "label", - "Value": "ComponentApp.styles.css" + "Value": "ComponentApp.modules.json" } ] }, { - "Route": "ComponentApp.modules.json.br", - "AssetFile": "${ProjectPath}\\obj\\Debug\\${Tfm}\\compressed\\publish\\_content\\ComponentApp\\ComponentApp.modules.json.br", + "Route": "ComponentApp.modules.json.gz", + "AssetFile": "${ProjectPath}\\obj\\Debug\\${Tfm}\\compressed\\publish\\_content\\ComponentApp\\ComponentApp#[.{fingerprint=__fingerprint__}]?.modules.json.gz", "Selectors": [], "ResponseHeaders": [ { @@ -2207,7 +2207,52 @@ }, { "Name": "Content-Encoding", - "Value": "br" + "Value": "gzip" + }, + { + "Name": "Content-Length", + "Value": "__content-length__" + }, + { + "Name": "Content-Type", + "Value": "application/json" + }, + { + "Name": "ETag", + "Value": "__etag__" + }, + { + "Name": "Last-Modified", + "Value": "__last-modified__" + }, + { + "Name": "Vary", + "Value": "Content-Encoding" + } + ], + "EndpointProperties": [ + { + "Name": "integrity", + "Value": "__integrity__" + } + ] + }, + { + "Route": "ComponentApp.eq4eem9pbl.modules.json.gz", + "AssetFile": "${ProjectPath}\\obj\\Debug\\${Tfm}\\compressed\\publish\\_content\\ComponentApp\\ComponentApp#[.{fingerprint=__fingerprint__}]?.modules.json.gz", + "Selectors": [], + "ResponseHeaders": [ + { + "Name": "Accept-Ranges", + "Value": "bytes" + }, + { + "Name": "Cache-Control", + "Value": "max-age=31536000, immutable" + }, + { + "Name": "Content-Encoding", + "Value": "gzip" }, { "Name": "Content-Length", @@ -2231,19 +2276,27 @@ } ], "EndpointProperties": [ + { + "Name": "fingerprint", + "Value": "__fingerprint__" + }, { "Name": "integrity", "Value": "__integrity__" + }, + { + "Name": "label", + "Value": "ComponentApp.modules.json.gz" } ] }, { "Route": "ComponentApp.modules.json", - "AssetFile": "${ProjectPath}\\obj\\Debug\\${Tfm}\\compressed\\publish\\_content\\ComponentApp\\ComponentApp.modules.json.br", + "AssetFile": "${ProjectPath}\\obj\\Debug\\${Tfm}\\compressed\\publish\\_content\\ComponentApp\\ComponentApp#[.{fingerprint=__fingerprint__}]?.modules.json.gz", "Selectors": [ { "Name": "Content-Encoding", - "Value": "br", + "Value": "gzip", "Quality": "__quality__" } ], @@ -2258,7 +2311,7 @@ }, { "Name": "Content-Encoding", - "Value": "br" + "Value": "gzip" }, { "Name": "Content-Length", @@ -2293,9 +2346,15 @@ ] }, { - "Route": "ComponentApp.modules.json.gz", - "AssetFile": "${ProjectPath}\\obj\\Debug\\${Tfm}\\compressed\\publish\\_content\\ComponentApp\\ComponentApp.modules.json.gz", - "Selectors": [], + "Route": "ComponentApp.eq4eem9pbl.modules.json", + "AssetFile": "${ProjectPath}\\obj\\Debug\\${Tfm}\\compressed\\publish\\_content\\ComponentApp\\ComponentApp#[.{fingerprint=__fingerprint__}]?.modules.json.gz", + "Selectors": [ + { + "Name": "Content-Encoding", + "Value": "gzip", + "Quality": "__quality__" + } + ], "ResponseHeaders": [ { "Name": "Accept-Ranges", @@ -2303,7 +2362,7 @@ }, { "Name": "Cache-Control", - "Value": "no-cache" + "Value": "max-age=31536000, immutable" }, { "Name": "Content-Encoding", @@ -2321,6 +2380,10 @@ "Name": "ETag", "Value": "__etag__" }, + { + "Name": "ETag", + "Value": "__etag__" + }, { "Name": "Last-Modified", "Value": "__last-modified__" @@ -2331,19 +2394,125 @@ } ], "EndpointProperties": [ + { + "Name": "fingerprint", + "Value": "__fingerprint__" + }, { "Name": "integrity", "Value": "__integrity__" + }, + { + "Name": "label", + "Value": "ComponentApp.modules.json" } ] }, { - "Route": "ComponentApp.modules.json", - "AssetFile": "${ProjectPath}\\obj\\Debug\\${Tfm}\\compressed\\publish\\_content\\ComponentApp\\ComponentApp.modules.json.gz", + "Route": "ComponentApp.styles.css.br", + "AssetFile": "${ProjectPath}\\obj\\Debug\\${Tfm}\\compressed\\publish\\_content\\ComponentApp\\ComponentApp#[.{fingerprint=__fingerprint__}]?.styles.css.br", + "Selectors": [], + "ResponseHeaders": [ + { + "Name": "Accept-Ranges", + "Value": "bytes" + }, + { + "Name": "Cache-Control", + "Value": "no-cache" + }, + { + "Name": "Content-Encoding", + "Value": "br" + }, + { + "Name": "Content-Length", + "Value": "__content-length__" + }, + { + "Name": "Content-Type", + "Value": "text/css" + }, + { + "Name": "ETag", + "Value": "__etag__" + }, + { + "Name": "Last-Modified", + "Value": "__last-modified__" + }, + { + "Name": "Vary", + "Value": "Content-Encoding" + } + ], + "EndpointProperties": [ + { + "Name": "integrity", + "Value": "__integrity__" + } + ] + }, + { + "Route": "ComponentApp.__fingerprint__.styles.css.br", + "AssetFile": "${ProjectPath}\\obj\\Debug\\${Tfm}\\compressed\\publish\\_content\\ComponentApp\\ComponentApp#[.{fingerprint=__fingerprint__}]?.styles.css.br", + "Selectors": [], + "ResponseHeaders": [ + { + "Name": "Accept-Ranges", + "Value": "bytes" + }, + { + "Name": "Cache-Control", + "Value": "max-age=31536000, immutable" + }, + { + "Name": "Content-Encoding", + "Value": "br" + }, + { + "Name": "Content-Length", + "Value": "__content-length__" + }, + { + "Name": "Content-Type", + "Value": "text/css" + }, + { + "Name": "ETag", + "Value": "__etag__" + }, + { + "Name": "Last-Modified", + "Value": "__last-modified__" + }, + { + "Name": "Vary", + "Value": "Content-Encoding" + } + ], + "EndpointProperties": [ + { + "Name": "fingerprint", + "Value": "__fingerprint__" + }, + { + "Name": "integrity", + "Value": "__integrity__" + }, + { + "Name": "label", + "Value": "ComponentApp.styles.css.br" + } + ] + }, + { + "Route": "ComponentApp.styles.css", + "AssetFile": "${ProjectPath}\\obj\\Debug\\${Tfm}\\compressed\\publish\\_content\\ComponentApp\\ComponentApp#[.{fingerprint=__fingerprint__}]?.styles.css.br", "Selectors": [ { "Name": "Content-Encoding", - "Value": "gzip", + "Value": "br", "Quality": "__quality__" } ], @@ -2358,7 +2527,7 @@ }, { "Name": "Content-Encoding", - "Value": "gzip" + "Value": "br" }, { "Name": "Content-Length", @@ -2366,7 +2535,7 @@ }, { "Name": "Content-Type", - "Value": "application/json" + "Value": "text/css" }, { "Name": "ETag", @@ -2392,6 +2561,69 @@ } ] }, + { + "Route": "ComponentApp.__fingerprint__.styles.css", + "AssetFile": "${ProjectPath}\\obj\\Debug\\${Tfm}\\compressed\\publish\\_content\\ComponentApp\\ComponentApp#[.{fingerprint=__fingerprint__}]?.styles.css.br", + "Selectors": [ + { + "Name": "Content-Encoding", + "Value": "br", + "Quality": "__quality__" + } + ], + "ResponseHeaders": [ + { + "Name": "Accept-Ranges", + "Value": "bytes" + }, + { + "Name": "Cache-Control", + "Value": "max-age=31536000, immutable" + }, + { + "Name": "Content-Encoding", + "Value": "br" + }, + { + "Name": "Content-Length", + "Value": "__content-length__" + }, + { + "Name": "Content-Type", + "Value": "text/css" + }, + { + "Name": "ETag", + "Value": "__etag__" + }, + { + "Name": "ETag", + "Value": "__etag__" + }, + { + "Name": "Last-Modified", + "Value": "__last-modified__" + }, + { + "Name": "Vary", + "Value": "Content-Encoding" + } + ], + "EndpointProperties": [ + { + "Name": "fingerprint", + "Value": "__fingerprint__" + }, + { + "Name": "integrity", + "Value": "__integrity__" + }, + { + "Name": "label", + "Value": "ComponentApp.styles.css" + } + ] + }, { "Route": "_framework/blazor.server.js.br", "AssetFile": "${ProjectPath}\\obj\\Debug\\${Tfm}\\compressed\\publish\\_content\\ComponentApp\\_framework\\blazor.server.js.br", @@ -2861,6 +3093,51 @@ } ] }, + { + "Route": "ComponentApp.eq4eem9pbl.modules.json", + "AssetFile": "${ProjectPath}\\obj\\Debug\\${Tfm}\\jsmodules\\jsmodules.publish.manifest.json", + "Selectors": [], + "ResponseHeaders": [ + { + "Name": "Accept-Ranges", + "Value": "bytes" + }, + { + "Name": "Cache-Control", + "Value": "max-age=31536000, immutable" + }, + { + "Name": "Content-Length", + "Value": "__content-length__" + }, + { + "Name": "Content-Type", + "Value": "application/json" + }, + { + "Name": "ETag", + "Value": "__etag__" + }, + { + "Name": "Last-Modified", + "Value": "__last-modified__" + } + ], + "EndpointProperties": [ + { + "Name": "fingerprint", + "Value": "__fingerprint__" + }, + { + "Name": "integrity", + "Value": "__integrity__" + }, + { + "Name": "label", + "Value": "ComponentApp.modules.json" + } + ] + }, { "Route": "ComponentApp.styles.css", "AssetFile": "${ProjectPath}\\obj\\Debug\\${Tfm}\\scopedcss\\bundle\\ComponentApp.styles.css", From fdc3c3b2d3997d73a1f570c973293229b7812622 Mon Sep 17 00:00:00 2001 From: Javier Calvarro Nelson Date: Thu, 27 Mar 2025 12:19:29 +0100 Subject: [PATCH 4/5] Fix baselines --- ...ndleToTheRightLocation.Publish.staticwebassets.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/Microsoft.NET.Sdk.Razor.Tests/StaticWebAssetsBaselines/Publish_PublishesJsModuleBundleBundleToTheRightLocation.Publish.staticwebassets.json b/test/Microsoft.NET.Sdk.Razor.Tests/StaticWebAssetsBaselines/Publish_PublishesJsModuleBundleBundleToTheRightLocation.Publish.staticwebassets.json index 005fcf44fbea..a574e912048f 100644 --- a/test/Microsoft.NET.Sdk.Razor.Tests/StaticWebAssetsBaselines/Publish_PublishesJsModuleBundleBundleToTheRightLocation.Publish.staticwebassets.json +++ b/test/Microsoft.NET.Sdk.Razor.Tests/StaticWebAssetsBaselines/Publish_PublishesJsModuleBundleBundleToTheRightLocation.Publish.staticwebassets.json @@ -2022,7 +2022,7 @@ ] }, { - "Route": "ComponentApp.eq4eem9pbl.modules.json.br", + "Route": "ComponentApp.__fingerprint__.modules.json.br", "AssetFile": "${ProjectPath}\\obj\\Debug\\${Tfm}\\compressed\\publish\\_content\\ComponentApp\\ComponentApp#[.{fingerprint=__fingerprint__}]?.modules.json.br", "Selectors": [], "ResponseHeaders": [ @@ -2130,7 +2130,7 @@ ] }, { - "Route": "ComponentApp.eq4eem9pbl.modules.json", + "Route": "ComponentApp.__fingerprint__.modules.json", "AssetFile": "${ProjectPath}\\obj\\Debug\\${Tfm}\\compressed\\publish\\_content\\ComponentApp\\ComponentApp#[.{fingerprint=__fingerprint__}]?.modules.json.br", "Selectors": [ { @@ -2238,7 +2238,7 @@ ] }, { - "Route": "ComponentApp.eq4eem9pbl.modules.json.gz", + "Route": "ComponentApp.__fingerprint__.modules.json.gz", "AssetFile": "${ProjectPath}\\obj\\Debug\\${Tfm}\\compressed\\publish\\_content\\ComponentApp\\ComponentApp#[.{fingerprint=__fingerprint__}]?.modules.json.gz", "Selectors": [], "ResponseHeaders": [ @@ -2346,7 +2346,7 @@ ] }, { - "Route": "ComponentApp.eq4eem9pbl.modules.json", + "Route": "ComponentApp.__fingerprint__.modules.json", "AssetFile": "${ProjectPath}\\obj\\Debug\\${Tfm}\\compressed\\publish\\_content\\ComponentApp\\ComponentApp#[.{fingerprint=__fingerprint__}]?.modules.json.gz", "Selectors": [ { @@ -3094,7 +3094,7 @@ ] }, { - "Route": "ComponentApp.eq4eem9pbl.modules.json", + "Route": "ComponentApp.__fingerprint__.modules.json", "AssetFile": "${ProjectPath}\\obj\\Debug\\${Tfm}\\jsmodules\\jsmodules.publish.manifest.json", "Selectors": [], "ResponseHeaders": [ From e78320f8b463823bbe67e4cb638b72952c8b2f89 Mon Sep 17 00:00:00 2001 From: Javier Calvarro Nelson Date: Thu, 27 Mar 2025 13:53:13 +0100 Subject: [PATCH 5/5] Fix regex --- .../StaticWebAssetsBaselineFactory.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/Microsoft.NET.Sdk.Razor.Tests/StaticWebAssetsBaselineFactory.cs b/test/Microsoft.NET.Sdk.Razor.Tests/StaticWebAssetsBaselineFactory.cs index 70f8467f3dec..aada23bdd62a 100644 --- a/test/Microsoft.NET.Sdk.Razor.Tests/StaticWebAssetsBaselineFactory.cs +++ b/test/Microsoft.NET.Sdk.Razor.Tests/StaticWebAssetsBaselineFactory.cs @@ -27,11 +27,15 @@ public partial class StaticWebAssetsBaselineFactory [GeneratedRegex("""(.*\.)([0123456789abcdefghijklmnopqrstuvwxyz]{10})(\.lib\.module\.js)((?:\.gz)|(?:\.br))?$""", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)] private static partial Regex JSInitializerRegex(); + [GeneratedRegex("""(.*\.)([0123456789abcdefghijklmnopqrstuvwxyz]{10})(\.modules\.json)((?:\.gz)|(?:\.br))?$""", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)] + private static partial Regex JSModuleManifestRegex(); + private static readonly IList<(Regex expression, string replacement)> WellKnownFileNamePatternsAndReplacements = [ (ScopedProjectBundleRegex(),"$1__fingerprint__$3$4"), (ScopedAppBundleRegex(),"$1__fingerprint__$3$4"), (JSInitializerRegex(), "$1__fingerprint__$3$4"), + (JSModuleManifestRegex(), "$1__fingerprint__$3$4"), (EmbeddedFingerprintExpression(), "#[.{fingerprint=__fingerprint__}]$1"), (FingerprintedSiteCssRegex(), "fingerprint-site$1__fingerprint__$3$4"), ];