The GitHub Actions security scan workflow was using the deprecated deno bundle command, which was removed in Deno 2.x. This caused the workflow to fail with errors like:
error: `deno bundle` was removed in Deno 2.
The deno bundle command was deprecated and removed in Deno 2.0+ in favor of more modern bundling solutions like:
- Third-party bundlers (Vite, esbuild, etc.)
deno compilefor creating standalone executables- Native ES modules and HTTP imports
We replaced the bundle size analysis with a direct source size calculation that:
- Sums all relevant TypeScript files in the project
- Provides the same size warnings as the original bundle analysis
- Works reliably across all Deno versions
- Gives more accurate insights into actual source code size
The new analysis calculates total source size by examining:
main.ts- Main application filetest_*.ts- All test files matching the patternsrc/*.ts- Any source files in src/ directory (if present)
# Calculate total source size
total_size=0
# Add main.ts
main_size=$(stat -f%z main.ts 2>/dev/null || stat -c%s main.ts)
total_size=$((total_size + main_size))
# Add test files
for test_file in test_*.ts; do
if [ -f "$test_file" ]; then
test_size=$(stat -f%z "$test_file" 2>/dev/null || stat -c%s "$test_file")
total_size=$((total_size + test_size))
fi
done
# Add src files (if directory exists)
if [ -d "src" ]; then
src_size=$(find src -name "*.ts" -type f -exec stat -f%z {} + 2>/dev/null | awk '{sum+=$1} END {print sum+0}')
total_size=$((total_size + src_size))
fiThe same warning thresholds are maintained:
- >1MB: Large size warning
- >512KB: Moderate size warning
- <512KB: Reasonable size ✅
As a bonus feature, we also added optional compiled executable size analysis using deno compile:
if deno compile --output proxy-executable main.ts 2>/dev/null; then
executable_size=$(stat -f%z proxy-executable 2>/dev/null || stat -c%s proxy-executable)
ratio=$((executable_size / total_size))
echo "Compilation ratio: ${ratio}x"
fiThis provides insights into:
- How the compiled executable size compares to source
- Compilation overhead and efficiency
- Deployment artifact size for standalone distributions
❌ error: `deno bundle` was removed in Deno 2.
Bundle size analysis FAILED
✅ Source size analysis:
main.ts: 8820 bytes
test_openai_responses_simple.ts: 8056 bytes
test_openai_responses.ts: 16424 bytes
test_server_startup.ts: 2230 bytes
Total source size: 35530 bytes (34 KB)
✅ Source size is reasonable (<512KB)
📦 Compiled executable: 86838078 bytes
📈 Compilation ratio: 2444x
- Works with all modern Deno versions
- No dependency on deprecated commands
- Future-proof implementation
- Measures actual source code size
- Includes all relevant project files
- Better reflects development complexity
- Source vs compiled size comparison
- File-by-file breakdown
- Compilation efficiency metrics
- Works on macOS (
stat -f%z) and Linux (stat -c%s) - Handles missing files gracefully
- Robust error handling
- Clear, readable shell script logic
- Easy to add new file patterns
- Configurable thresholds
A comprehensive test script (test_source_size.sh) was created to validate the logic:
./test_source_size.sh
✅ SUCCESS: Source size calculation logic works correctly
- Files found: 4
- Total source size: 35530 bytes
- Size category: Reasonable <512KBIf you have similar deno bundle usage in your projects:
- name: Bundle size analysis
run: |
deno bundle main.ts bundle.js
bundle_size=$(stat -c%s bundle.js)
echo "Bundle size: $bundle_size bytes"- name: Source size analysis
run: |
total_size=0
for file in main.ts test_*.ts; do
if [ -f "$file" ]; then
size=$(stat -f%z "$file" 2>/dev/null || stat -c%s "$file")
total_size=$((total_size + size))
fi
done
echo "Total source size: $total_size bytes"- Vite: Modern bundler with excellent Deno support
- esbuild: Fast bundler with TypeScript support
- Pros: Industry standard, feature-rich
- Cons: Additional dependencies, complexity
- Approach: Use compiled executable size as metric
- Pros: Real deployment artifact size
- Cons: Much larger than source (2000x+), less useful for development
- Approach: Sum actual source file sizes
- Pros: Simple, accurate, no dependencies
- Cons: Doesn't reflect final bundle optimizations
The direct source size analysis provides a practical, maintainable solution that:
- ✅ Fixes the Deno 2.x compatibility issue
- ✅ Provides meaningful size metrics for development
- ✅ Maintains the same warning thresholds
- ✅ Adds valuable compilation insights
- ✅ Works reliably across platforms
This approach balances simplicity with functionality, giving developers the information they need to monitor code size growth without the complexity of external bundlers.