build: add bundle-size analysis tooling + baseline report + 500 kB gate#31
build: add bundle-size analysis tooling + baseline report + 500 kB gate#31adm01-debug wants to merge 1 commit into
Conversation
The current build is healthy (no chunk > 500 kB gzip) but there was no tooling to verify that or detect regressions. The 'rollup-plugin- visualizer' is wired in vite.config.ts but its 'mode === production' conditional doesn't reliably emit dist/stats.html on the current Vite version, leaving no post-build view of the bundle. ## What's added ### scripts/bundle-analysis.mjs Standalone analyzer that walks dist/assets/.js, computes raw + gzip sizes, buckets chunks by category (vendor:*, page:admin, page:other, hook, ui:overlay, app:entry, lazy:chunk), and emits: - Human table to stdout (default) - JSON to stdout (--json) - Markdown to docs/BUNDLE_REPORT.md (--md) - Exit 1 if any chunk > 500 kB gzip (--check) — for CI gate ### npm scripts build:analyze → vite build && analyze build:analyze:md → vite build && write report to docs/BUNDLE_REPORT.md build:analyze:check → vite build && fail if > 500 kB gzip chunk exists ### docs/BUNDLE_ANALYSIS.md Narrative analysis: current baseline (~2.97 MB gzip across 294 chunks, no offenders), top offender table with raw + gzip sizes, prioritized optimization plan (medium: lucide-react tree-shaking saves 80-100 kB gzip; medium: split AdminConexoesPage explain-mode), and a suggested CI workflow snippet to enforce the 500 kB gate.
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Update on the lucide-react tree-shaking suggestion (§ Optimization opportunities, 🟡 Medium)I tested the suggested codemod (rewriting
Result: zero size change. Why it's a no-op
Implication for
|
Summary
Adds bundle-size analysis tooling, a baseline report, an optimization plan, and a CI-ready 500 kB gzip gate.
Why
The build is currently healthy — no chunk exceeds 500 kB gzip — but there was no tooling to verify that or to detect regressions.
rollup-plugin-visualizeris wired invite.config.tsbut itsmode === 'production'conditional doesn't reliably emitdist/stats.htmlon the current Vite version, leaving no post-build view of the bundle.Current baseline
What's added
scripts/bundle-analysis.mjsStandalone analyzer that walks
dist/assets/*.js, computes raw + gzip sizes, buckets chunks by category (vendor:*,page:admin,page:other,hook,ui:overlay,app:entry,lazy:chunk), and emits:--json)docs/BUNDLE_REPORT.md(--md)--check) — for CI gatenpm scripts
docs/BUNDLE_ANALYSIS.md+docs/BUNDLE_REPORT.mdBUNDLE_ANALYSIS.md— narrative: current state, top offender table, prioritized optimization plan (medium:lucide-reacttree-shaking ≈ 80–100 kB gzip savings; medium: splitAdminConexoesPageexplain-mode), CI workflow snippetBUNDLE_REPORT.md— auto-generated machine output (top 15 chunks, by-category breakdown, flagged offenders)CI gate (suggested follow-up)
Hard error at 500 kB gzip rather than soft warn — that's the threshold where mobile TTI starts to degrade meaningfully.
Test plan
node scripts/bundle-analysis.mjs— works on currentdist/node scripts/bundle-analysis.mjs --md— writesdocs/BUNDLE_REPORT.mdnode scripts/bundle-analysis.mjs --check— exits 0 (no offenders today)npm run build:analyze— full pipelinehttps://claude.ai/code/session_01KWeDG
Generated by Claude Code