perf(build): merge stats.toJson calls#6351
Conversation
✅ Deploy Preview for rsbuild ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Pull Request Overview
This PR optimizes build performance by consolidating stats.toJson() calls to reduce overhead and enable future reuse of assets information. The changes refactor how webpack/rspack stats are processed during the build phase.
Key changes:
- Modified stats collection to include assets information in a single call
- Updated the file size plugin to use pre-computed stats instead of making separate calls
- Refactored stats options handling to conditionally include assets data based on build action
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/core/src/types/rsbuild.ts | Added 'assets' to the RsbuildStatsItem type definition |
| packages/core/src/plugins/fileSize.ts | Updated to use pre-computed stats from context instead of making separate stats calls |
| packages/core/src/helpers/stats.ts | Refactored stats options to conditionally include assets data and extracted reusable options |
Comments suppressed due to low confidence (1)
packages/core/src/helpers/stats.ts:1
- The reassignment pattern with object spread creates unnecessary overhead. Since the base object is the same, consider defining separate option objects for each condition or using Object.assign for better performance.
import { logger } from '../logger';
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting

Summary
Merge the
stats.toJson()calls during the build to reduce the overhead slightly and allow reuse of assets info in the future.Checklist