From ceca4c2ad1f8bac7044b258aa2d53b409cd076e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Go=C5=82e=CC=A8biowski-Owczarek?= Date: Fri, 10 May 2024 15:59:14 +0200 Subject: [PATCH 1/3] 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. --- Gruntfile.js | 14 +++++++++++--- package.json | 1 + 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 9ee1986bc9..25c152a082 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -2,6 +2,8 @@ module.exports = function( grunt ) { +const gzip = require( "gzip-js" ); + // files const coreFiles = [ "core.js", @@ -75,7 +77,15 @@ const compareFiles = { all: [ "dist/jquery-ui.js", "dist/jquery-ui.min.js" - ] + ], + options: { + compress: { + gz: function( contents ) { + return gzip.zip( 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 ) ]; } ); diff --git a/package.json b/package.json index 081eb81d1d..5a6b4fac7e 100644 --- a/package.json +++ b/package.json @@ -74,6 +74,7 @@ "grunt-eslint": "24.0.1", "grunt-git-authors": "3.2.0", "grunt-html": "16.0.0", + "gzip-js": "0.3.2", "load-grunt-tasks": "5.1.0", "rimraf": "4.4.1", "selenium-webdriver": "4.18.1", From 024ee939551c2be6691695aa551cf10a9a4d35ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Go=C5=82e=CC=A8biowski-Owczarek?= Date: Sun, 19 May 2024 00:27:15 +0200 Subject: [PATCH 2/3] fixup! Build: Report compressed sizes in compare_size --- Gruntfile.js | 4 ++-- package.json | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 25c152a082..1f0d2bbfd3 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -2,7 +2,7 @@ module.exports = function( grunt ) { -const gzip = require( "gzip-js" ); +const { gzipSync } = require( "node:zlib" ); // files const coreFiles = [ @@ -81,7 +81,7 @@ const compareFiles = { options: { compress: { gz: function( contents ) { - return gzip.zip( contents, {} ).length; + return gzipSync( contents ).length; } }, cache: "build/.sizecache.json" diff --git a/package.json b/package.json index 5a6b4fac7e..081eb81d1d 100644 --- a/package.json +++ b/package.json @@ -74,7 +74,6 @@ "grunt-eslint": "24.0.1", "grunt-git-authors": "3.2.0", "grunt-html": "16.0.0", - "gzip-js": "0.3.2", "load-grunt-tasks": "5.1.0", "rimraf": "4.4.1", "selenium-webdriver": "4.18.1", From d72957221540edd27bdffb6118fc000f6ffb578f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Go=C5=82e=CC=A8biowski-Owczarek?= Date: Sun, 19 May 2024 23:30:26 +0200 Subject: [PATCH 3/3] fixup! Build: Report compressed sizes in compare_size --- Gruntfile.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 1f0d2bbfd3..d6707becad 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -2,8 +2,6 @@ module.exports = function( grunt ) { -const { gzipSync } = require( "node:zlib" ); - // files const coreFiles = [ "core.js", @@ -81,6 +79,8 @@ const compareFiles = { options: { compress: { gz: function( contents ) { + const { gzipSync } = require( "node:zlib" ); + return gzipSync( contents ).length; } },