File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed
Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change 9898 "test:node-fetch" : " USE_FETCH=1 npm run test:node" ,
9999 "test:browser" : " zuul test/index.js" ,
100100 "build" : " rollup -c support/rollup.config.umd.js && rollup -c support/rollup.config.esm.js" ,
101+ "bundle-size" : " node support/bundle-size.js" ,
101102 "format:check" : " prettier --check 'lib/**/*.ts' 'test/**/*.js' 'test/webtransport.mjs' 'support/**/*.js'" ,
102103 "format:fix" : " prettier --write 'lib/**/*.ts' 'test/**/*.js' 'test/webtransport.mjs' 'support/**/*.js'" ,
103104 "prepack" : " npm run compile"
Original file line number Diff line number Diff line change 1+ const { resolve } = require ( "node:path" ) ;
2+ const { readFile } = require ( "node:fs/promises" ) ;
3+ const { gzipSync, brotliCompressSync } = require ( "node:zlib" ) ;
4+
5+ const bundles = [
6+ {
7+ name : "UMD bundle" ,
8+ path : "dist/engine.io.min.js" ,
9+ } ,
10+ {
11+ name : "ESM bundle" ,
12+ path : "dist/engine.io.esm.min.js" ,
13+ } ,
14+ ] ;
15+
16+ function format ( size ) {
17+ return ( size / 1024 ) . toFixed ( 1 ) ;
18+ }
19+
20+ async function main ( ) {
21+ for ( const bundle of bundles ) {
22+ const path = resolve ( bundle . path ) ;
23+ const content = await readFile ( path ) ;
24+ const gzip = gzipSync ( content ) ;
25+ const brotli = brotliCompressSync ( content ) ;
26+
27+ console . log ( `${ bundle . name } ` ) ;
28+ console . log ( `min: ${ format ( content . length ) } KB` ) ;
29+ console . log ( `min+gzip: ${ format ( gzip . length ) } KB` ) ;
30+ console . log ( `min+br: ${ format ( brotli . length ) } KB` ) ;
31+ console . log ( ) ;
32+ }
33+ }
34+
35+ main ( ) ;
You can’t perform that action at this time.
0 commit comments