Last active
March 14, 2025 12:04
-
-
Save suhaotian/42155e2ea7ca54c0eb383e3738eff0ec to your computer and use it in GitHub Desktop.
Get your lib bundle size with bun
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Create a temporary file | |
TMP_FILE=$(mktemp) | |
# Build and save output to temp file | |
bun build dist/index.mjs --minify > "$TMP_FILE" | |
# Get original size | |
SIZE=$(cat "$TMP_FILE" | wc -c | awk '{comp=$1/1024; printf "%.2f", comp}') | |
echo "Size: $SIZE KB" | |
# Get gzipped size | |
GZIP_SIZE=$(cat "$TMP_FILE" | gzip -c | wc -c | awk '{comp=$1/1024; printf "%.2f", comp}') | |
echo "Gzip: $GZIP_SIZE KB" | |
# Clean up | |
rm "$TMP_FILE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment