Build: Report compressed sizes in compare_size

Just like it has always worked in Core. This will help with size comparisons
between 1.13 & 1.14.

After this PR:

```
$ grunt sizer
Running "requirejs:js" (requirejs) task

Running "uglify:main" (uglify) task
>> 1 file created 549 kB → 267 kB

Running "compare_size:all" (compare_size) task
   raw     gz Sizes
549319 128757 dist/jquery-ui.js
266710  69612 dist/jquery-ui.min.js

Done.
```

Before, only the less interesting `raw` sizes were reported.

Closes gh-2248
Ref gh-2254
This commit is contained in:
Michał Gołębiowski-Owczarek 2024-05-20 19:00:31 +02:00 committed by GitHub
parent 795b773640
commit f0174261a4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -75,7 +75,17 @@ const compareFiles = {
all: [
"dist/jquery-ui.js",
"dist/jquery-ui.min.js"
]
],
options: {
compress: {
gz: function( contents ) {
const { gzipSync } = require( "node:zlib" );
return gzipSync( contents ).length;
}
},
cache: "build/.sizecache.json"
}
};
const htmllintBad = [
@ -115,8 +125,6 @@ uiFiles.concat( allI18nFiles ).forEach( function( file ) {
} );
uiFiles.forEach( function( file ) {
// TODO this doesn't do anything until https://github.com/rwldrn/grunt-compare-size/issues/13
compareFiles[ file ] = [ file, mapMinFile( file ) ];
} );