-
Notifications
You must be signed in to change notification settings - Fork 10.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use minified .js files from submodule in source-build (#56864)
* Use minified .js files from submodule in source-build * Fixup * Fixup again * Add check for changes to minified .js files * Fix typo * Add doc * Fix md error * Update Microsoft.AspNetCore.Components.Endpoints.csproj * Fix script * Update submodule * Print it * Upload the .js files as part of the build * Update submodule
- Loading branch information
Showing
11 changed files
with
64 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Updating minified .js files | ||
|
||
Building our `src/Components` projects will produce minified.js files under `src/Components/Web.JS/dist/Release`. In order to avoid constant merge conflicts, and to avoid having to restore NPM components over the network during offline source-build, we keep the latest versions of those files in a submodule repo, https://github.com/dotnet/blazorminifiedjs. If you are prepping a PR that is going to change the contents of those files, please follow the steps in this doc. | ||
|
||
1. Build the node components of the repo | ||
1. Running `npm run build` from the repo root should be sufficient, assuming you have already installed the prereqs listed in our [Building from source doc](https://github.com/dotnet/aspnetcore/edit/main/docs/BuildFromSource.md). | ||
2. In a separate folder, clone the [BlazorMinifiedJs repo](https://github.com/dotnet/blazorminifiedjs). | ||
3. Check out a new branch in your clone, based off of `main`. | ||
4. Replace the files in `BlazorMinifiedJs/src` with the minified .js files you just generated in aspnetcore (these can be found at `aspnetcore/src/Components/Web.JS/dist/Release`). | ||
5. Push your `BlazorMinifiedJs` branch and open a PR in that repo. | ||
6. Once that PR has been merged, return to your aspnetcore PR, navigate to `src/submodules/BlazorMinifiedJs`, and checkout the commit you just pushed. | ||
7. Push the submodule update to your aspnetcore PR. | ||
|
||
Alternatively, you can find the generated .js files in the artifacts of your PR build, under the artifact named "Minified_JS_Files". This may be more reliable than building the node components locally. | ||
|
||
Following these steps should remediate any build errors related to `BlazorMinifiedJs` in your PR. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
[string[]] $errors = @() | ||
|
||
function _compareFiles($fileName) { | ||
Write-Host "Comparing contents for $fileName" | ||
$repoRoot = Resolve-Path "$PSScriptRoot/../.." | ||
$localFile = "$repoRoot/src/Components/Web.JS/dist/Release/$fileName" | ||
$submoduleFile = "$repoRoot/src/submodules/BlazorMinifiedJs/src/$fileName" | ||
$delta = Compare-Object -ReferenceObject ((Get-Content -Path $submoduleFile).trim()) -DifferenceObject ((Get-Content -Path $localFile).trim()) | ||
if (![string]::IsNullOrEmpty($delta)) { | ||
$script:errors += "Diff found in $fileName, please see https://github.com/dotnet/aspnetcore/blob/main/docs/UpdatingMinifiedJsFiles.md for remediation steps" | ||
} | ||
} | ||
|
||
$MinifiedJsFiles = "blazor.web.js","blazor.server.js","blazor.webview.js" | ||
|
||
foreach ($JsFile in $MinifiedJsFiles) { | ||
_compareFiles -fileName $JsFile | ||
} | ||
|
||
foreach ($err in $errors) { | ||
Write-Host -f Red $err | ||
} | ||
|
||
if ($errors) { | ||
exit 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule BlazorMinifiedJs
added at
42f116