feat: add profile export command#38
Conversation
Export profiling data in React DevTools Profiler JSON format (version 5) so it can be imported into the browser extension's Profiler tab. - New IPC command: profile-export - New CLI command: profile export <file> - Maps internal ProfilingSession to ProfilingDataExport schema - Includes commit data, fiber durations, change descriptions, snapshots Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: e456530 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
CC @piotrski |
|
Nice work, thanks for the contribution! I tested this end-to-end with the Vite example app and found a few issues that I've fixed in Fixes:
|
processProfilingData() rejected data when stoppedAt was set, but stopProfilingAndCollect() requests data from renderers asynchronously — the response often arrives after profiler.stop() has already run, resulting in 0 commits captured. Remove the stoppedAt guard since the bridge controls data collection timing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
key was typed as number | string | null but ComponentNode.key is string | null — the number case was unreachable. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The profile export was producing broken flame graphs because we discarded the raw profiling payload and reconstructed it with missing/incorrect data (empty operations, null effect durations, wrong base durations). - Store raw per-root data from React DevTools for export passthrough - Capture additional commit fields (effectDuration, priorityLevel, etc.) - Build snapshots from ComponentTree (protocol sends them empty) - Extract export logic into profile-export.ts for clarity - Fix all tree nodes included in initialTreeBaseDurations Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Thanks for the fixes! Merged them into the branch. One thing I wanted to check - my earlier commits had a raw data passthrough that preserved some extra commit-level fields on export:
With the current approach these end up as |
Summary
profile export <file>CLI command that exports profiling data in React DevTools Profiler JSON format (version 5)ProfilingSessiondata to theProfilingDataExportschema: commits, fiber durations, change descriptions, and component tree snapshotsUsage
Then open React DevTools Profiler tab and click the import button to load the JSON file.
What's included in the export
commitDataProfilingSession.commitssnapshotsComponentTreenodesinitialTreeBaseDurationsfiberSelfDurationsoperationseffectDuration/passiveEffectDurationnullTest plan