From 65ff9ef9364301490043e7e2f30870f00008d882 Mon Sep 17 00:00:00 2001 From: jaywcjlove <398188662@qq.com> Date: Wed, 17 Apr 2024 23:07:21 +0800 Subject: [PATCH] chore: update scripts. --- package.json | 7 +++---- scripts/build.js | 10 ++++------ 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 442ff20..8cd6f0f 100644 --- a/package.json +++ b/package.json @@ -47,9 +47,8 @@ "@type-challenges/utils": "0.1.1", "bannerjs": "2.0.1", "colors-cli": "^1.0.29", + "pako": "^2.1.0", "rollup": "^3.17.3", - "tsbb": "^4.0.5", - "zlib": "1.0.5" - }, - "dependencies": {} + "tsbb": "^4.0.5" + } } diff --git a/scripts/build.js b/scripts/build.js index ad93146..fdee922 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -4,7 +4,7 @@ const nodeResolve = require('@rollup/plugin-node-resolve'); const commonjs = require('@rollup/plugin-commonjs'); const terser = require('@rollup/plugin-terser'); const banner = require('bannerjs'); -const zlib = require('zlib'); +const pako = require('pako'); require('colors-cli/toxic'); // see below for details on the options @@ -60,11 +60,9 @@ const inputOptions = { function report(result, outpath, extra) { const code = result.output[0].code; - zlib.gzip(code, (_err, zipped) => { - if (_err) return reject(_err); - extra = `(gzipped: ${getSize(zipped).green_bt})`; - console.log(`${(outpath).blue_bt} ${getSize(code).green_bt + (extra || '')}`); - }); + const compressed = pako.deflate(code); + extra = ` (gzipped: ${(compressed.length / 1024).toFixed(2).green_bt} kb)` + console.log(`${(outpath).blue_bt} ${getSize(code).green_bt + (extra || '')}`); } function getSize(code) {