Files
upstream-mirror 3a013ccdfe
Some checks failed
autofix.ci / autofix (push) Failing after 4s
Release / Release (push) Has been skipped
GitHub Actions Security Analysis / Run zizmor (push) Failing after 2s
snapshot of https://github.com/TanStack/query.git (main, 2026-09-16; blobs > 131072B omitted)
2026-09-16 01:13:08 +05:00

44 lines
1.2 KiB
JavaScript

import { readFile, readdir, stat } from 'node:fs/promises'
import path from 'node:path'
import { gzipSync } from 'node:zlib'
import { fileURLToPath } from 'node:url'
const scriptDir = path.dirname(fileURLToPath(import.meta.url))
const repoRoot = path.resolve(scriptDir, '..')
const distDir = path.join(repoRoot, 'build', 'modern')
const entryFile = path.join(distDir, 'index.js')
async function getDirSizeBytes(dirPath) {
let total = 0
const entries = await readdir(dirPath, { withFileTypes: true })
for (const entry of entries) {
const fullPath = path.join(dirPath, entry.name)
if (entry.isDirectory()) {
total += await getDirSizeBytes(fullPath)
} else if (entry.isFile()) {
total += (await stat(fullPath)).size
}
}
return total
}
async function run() {
const entry = await readFile(entryFile)
const entryGzip = gzipSync(entry)
const distBytes = await getDirSizeBytes(distDir)
const output = {
measuredAt: new Date().toISOString(),
entryJsBytes: entry.length,
entryJsGzipBytes: entryGzip.length,
distTotalBytes: distBytes,
}
console.log(JSON.stringify(output, null, 2))
}
run().catch((error) => {
console.error(error)
process.exit(1)
})