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

Compress the embedded config jsons #2533

Closed
wants to merge 7 commits into from
Closed

Compress the embedded config jsons #2533

wants to merge 7 commits into from

Conversation

psyirius
Copy link
Contributor

@psyirius psyirius commented Aug 7, 2024

Title

Compress the embedded config jsons

Type of Change

  • Releng Optimization

Description

Compress the config json embedding in the final build artifact

Impact

Reduces artifact size resulting in less traffic when fetching.

Checklist

  • My code adheres to the coding and style guidelines of the project.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no errors/warnings/merge conflicts.

@psyirius
Copy link
Contributor Author

psyirius commented Aug 7, 2024

WARNING

This will mess up the readability of the final build artifact.

If concerned about readability don't merge this!

@ChrisTitusTech ChrisTitusTech force-pushed the main branch 2 times, most recently from 7805fe4 to cfb9edb Compare August 26, 2024 22:01
@Marterich
Copy link
Contributor

Another Idea, if we are going the way of reducing the filesize and ignoring readability you could also think about adding a function like the following example to remove all Powershell Comments from the final compiled file.
This will remove an additional ~2k lines and therefore around 50-60kb

function Remove-PSComments {
    param (
        [string]$FilePath
    )
    if (-not (Test-Path $FilePath)) {
        throw "File '$FilePath' does not exist."
    }
    $content = Get-Content $FilePath -Raw
    # Remove block comments: <# ... #>
    $content = [regex]::Replace($content, '<#.*?#>', '', [System.Text.RegularExpressions.RegexOptions]::Singleline)
    # Remove line comments: # ...
    $content = [regex]::Replace($content, '(^|\s)#.*', '$1')
    # Remove empty lines (lines containing only whitespace or nothing)
    $content = [regex]::Replace($content, '^\s*[\r\n]+', '', [System.Text.RegularExpressions.RegexOptions]::Multiline)
    return $content
}
# Example usage:
Remove-PSComments -FilePath "winutil.ps1" | Set-Content "winutil_minified.ps1"

@psyirius
Copy link
Contributor Author

I have a feeling that it might not align with the vision of the project!
Closing it!

@psyirius psyirius closed this Aug 30, 2024
@psyirius psyirius deleted the config-compress branch August 30, 2024 05:02
@ChrisTitusTech ChrisTitusTech added the skip-changelog Skip Change Logs label Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip-changelog Skip Change Logs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants