Date: July 30, 2026
Branch: infra-39-bundle-size-optimization
Issue: #647 (INFRA-39)
- ✅ Added
@next/bundle-analyzer@16.2.3as exact-pinned devDependency infrontend/package.json - ✅ Integrated
withBundleAnalyzerinfrontend/next.config.ts- Wraps the Next.js config
- Gated behind
ANALYZE=trueenvironment variable - Does not run on normal builds (zero performance impact)
- ✅ Added
npm run analyzescript tofrontend/package.json- Command:
ANALYZE=true npm run build - Generates interactive HTML bundle report at
.next/analyze/
- Command:
- ✅
next.config.tsproperly imports and wrapswithNextIntlwithwithBundleAnalyzer - ✅ Environment variable gating prevents analyzer from running except when explicitly enabled
- ✅ Compatible with existing Next.js setup (App Router)
- ✅
BUNDLE_ANALYSIS_SETUP.md— Setup details, Windows npm issue workarounds, next steps - ✅
BUNDLE_OPTIMIZATION_PLAN.md— Detailed workflow, measurement approach, example optimizations, expected PR content - ✅
PROGRESS_SUMMARY.md— This file
- ✅ Created branch:
infra-39-bundle-size-optimization - ✅ Committed setup: "chore(INFRA-39): Add @next/bundle-analyzer and analyze script"
Status: npm install command is timing out on Windows.
Root Cause: Windows has a 260-character path limit (even with long path support enabled). The monorepo structure + deep node_modules nesting causes many paths to exceed this limit, resulting in npm install stalling or timing out.
Impact: Cannot proceed to bundle analysis phase until dependencies are installed.
Workarounds:
- Linux/WSL2 — Run npm install on Linux, WSL2, or Docker. Windows is not blocking this in CI (GitHub Actions runs on Ubuntu).
- CI — The pipeline can proceed once merged because CI runs on Ubuntu where there are no path length limits.
- Docker — Use a Docker container to run npm install if WSL2 is not available.
- Monorepo restructuring — Move to pnpm or yarn workspaces (out of scope for this issue).
Current Attempt: npm install running in background process (started 20+ minutes ago, still in progress).
- Wait for background process to complete, OR
- Switch to Linux/WSL2/Docker environment
- Result: working
node_modules/with @next/bundle-analyzer installed
cd frontend
npm run analyze- Generates
frontend/.next/analyze/client.htmlandserver.html - Open in browser and inspect the treemap visualization
- Document baseline bundle sizes
From the analyzer output, identify:
- Wholesale imports of large libraries (icon libs, utilities)
- Non-tree-shakeable code patterns (default imports of barrels)
- Heavy components not on critical path (code-split candidates)
- Duplicate package versions
For each finding:
- Make specific import change or code-split
- Re-run
npm run analyze - Measure size delta
- Commit only if delta is real
- Update
frontend/budget.jsonthresholds based on post-optimization baseline - Add size-budget check to
.github/workflows/frontend.yml
- Evidence-based changes only (measured deltas for each fix)
- Before/after bundle sizes documented
- Test results (lint, build, tests)
- Clear description of what was found and why each fix worked
-
frontend/package.json- Added
"analyze": "ANALYZE=true npm run build"script - Added
"@next/bundle-analyzer": "16.2.3"devDependency (exact pinned)
- Added
-
frontend/next.config.ts- Added import:
import withBundleAnalyzer from "@next/bundle-analyzer" - Wrapped config:
export default withBundleAnalyzer({ enabled: process.env.ANALYZE === "true" })(withNextIntl(nextConfig))
- Added import:
frontend/budget.json— Will update once we have actual post-optimization baseline.github/workflows/frontend.yml— Will add size-budget check step once thresholds determined- App code — No changes yet; analysis phase is non-invasive
Once npm install completes and we can run the analyzer:
Baseline (Before Optimization):
- Client-side JS (first load): ___ KB
- Server-side JS: ___ KB
- Top 5 largest packages: ___
Target (After Optimization):
- Client-side JS (first load): ___ KB (goal: -15% to -25% from baseline)
- Server-side JS: ___ KB
- Budget threshold in CI: ___ KB (baseline + 10% headroom)
# Once npm install completes:
cd frontend
npm run analyze
# Open ./next/analyze/client.html and ./next/analyze/server.html
# For each optimization:
npm run build # Measure bundle size from build output
npm run analyze # Compare against previous analyzer run
# Before PR:
npm run lint
npm run build
npm run test
npm run test:e2e- npm install completes successfully
- npm run analyze runs without error
- Baseline bundle sizes documented
- Large contributors identified from analyzer
- First optimization applied and measured
- CI size-budget check added
- PR ready for review with evidence-based changes and measurements
- PR merged to main
-
Evidence-driven only: Every claimed optimization must have before/after measurements from the analyzer. No assumptions.
-
Windows npm issue is known: This is a well-documented issue with monorepos on Windows. It does not block CI, where npm install works fine on Ubuntu.
-
Non-blocking locally: If stuck on local Windows npm install, the work can proceed in CI or on a Linux/WSL2 environment.
-
Rollback is safe: The current setup is minimal and entirely in config. If something goes wrong, one git revert removes all changes.
-
Bundle analyzer is zero-cost: It only runs when explicitly enabled via
ANALYZE=true. Normalnpm run buildand dev runs are unaffected.
Questions or blockers? Check BUNDLE_ANALYSIS_SETUP.md for common issues and workarounds.