File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
packages/bundle-size-checker/src Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change 1
1
import path from 'path' ;
2
2
import fs from 'fs/promises' ;
3
- import { gzipSync } from 'zlib' ;
3
+ import * as zlib from 'zlib' ;
4
+ import { promisify } from 'util' ;
5
+
6
+ const gzipAsync = promisify ( zlib . gzip ) ;
4
7
import { build , transformWithEsbuild } from 'vite' ;
5
8
import { visualizer } from 'rollup-plugin-visualizer' ;
6
9
@@ -199,11 +202,12 @@ async function processBundleSizes(outDir, entryName) {
199
202
200
203
// Calculate sizes
201
204
const parsed = Buffer . byteLength ( fileContent ) ;
202
- const gzip = Buffer . byteLength ( gzipSync ( fileContent ) ) ;
205
+ const gzipBuffer = await gzipAsync ( fileContent , { level : zlib . constants . Z_BEST_COMPRESSION } ) ;
206
+ const gzipSize = Buffer . byteLength ( gzipBuffer ) ;
203
207
204
208
// Use chunk key as the name, or fallback to entry name for main chunk
205
209
const chunkName = chunkKey === 'virtual:entry.tsx' ? entryName : chunkKey ;
206
- return /** @type {const } */ ( [ chunkName , { parsed, gzip } ] ) ;
210
+ return /** @type {const } */ ( [ chunkName , { parsed, gzip : gzipSize } ] ) ;
207
211
} ) ;
208
212
209
213
const chunkEntries = await Promise . all ( chunkPromises ) ;
You can’t perform that action at this time.
0 commit comments