Performance Monitor
Real-time bundle analyzer and runtime performance tracker for React apps.
Overview
A development tool that provides real-time insights into React application performance, combining bundle analysis with runtime metrics. Shows component render times, bundle composition, and identifies performance bottlenecks as you develop, without switching to the browser DevTools.
Architecture
Bundle analysis (Vite plugin)
Hooks into esbuild's build pipeline via the generateBundle hook. Reads esbuild's metafile (enabled via metafile: true) to get input/output size relationships. Streams this data to a WebSocket server on build completion and on HMR updates.
Runtime monitoring (React component)
A <PerformanceMonitor> wrapper uses React Profiler API to collect render timing. Performance Observer API captures LCP, CLS, INP, and resource timing. All data flows to a local dashboard at localhost:4000.
Key Features
The monitor uses a 10% sampling rate by default for React Profiler data. At 100% sampling, the observer itself becomes a measurable overhead. Sampling gives statistically accurate data with minimal impact on actual render performance. The dashboard aggregates across samples to show accurate percentiles.
WebSocket Reconnection
CI Integration
The plugin can run in CI mode: no WebSocket server, outputs a JSON report instead. Configured via PERF_MONITOR_CI=true. CI mode compares the current build against a baseline stored in .perf-baseline.json and exits non-zero if any threshold is exceeded.
Tech Stack
Vite · esbuild · React · Performance Observer API · React Profiler API · WebSockets · Node.js