/
githubmirror
/
socket.io
Обзор
Документация
Войти
/
githubmirror
/
socket.io
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
packages/engine.io-client/support/bundle-size.js
35 строк
839 B
Damien Arrachequesne
refactor: prepare the migration to a monorepo
08 июл 2024, 11:59
Не верифицирован
08 июл 2024, 11:59
32a1a60
Код
Авторство
О чём код?
const { resolve } = require("node:path"); const { readFile } = require("node:fs/promises"); const { gzipSync, brotliCompressSync } = require("node:zlib"); const bundles = [ { name: "UMD bundle", path: "dist/engine.io.min.js", }, { name: "ESM bundle", path: "dist/engine.io.esm.min.js", }, ]; function format(size) { return (size / 1024).toFixed(1); } async function main() { for (const bundle of bundles) { const path = resolve(bundle.path); const content = await readFile(path); const gzip = gzipSync(content); const brotli = brotliCompressSync(content); console.log(`${bundle.name}`); console.log(`min: ${format(content.length)} KB`); console.log(`min+gzip: ${format(gzip.length)} KB`); console.log(`min+br: ${format(brotli.length)} KB`); console.log(); } } main();