From f0174261a47661b2dd39ed5bb0d6bd28bd60029e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Go=C5=82=C4=99biowski-Owczarek?= <m.goleb@gmail.com> Date: Mon, 20 May 2024 19:00:31 +0200 Subject: [PATCH] Build: Report compressed sizes in compare_size MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- Gruntfile.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 9ee1986bc9..d6707becad 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -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 ) ]; } );