Skip to content

perf(build): merge stats.toJson calls#6351

Merged
chenjiahan merged 1 commit intomainfrom
build_stats_to_json_1013
Oct 13, 2025
Merged

perf(build): merge stats.toJson calls#6351
chenjiahan merged 1 commit intomainfrom
build_stats_to_json_1013

Conversation

@chenjiahan
Copy link
Member

Summary

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

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings October 13, 2025 05:19
@netlify
Copy link

netlify bot commented Oct 13, 2025

Deploy Preview for rsbuild ready!

Name Link
🔨 Latest commit 6e124dd
🔍 Latest deploy log https://app.netlify.com/projects/rsbuild/deploys/68ec8bde4130d700084cffe0
😎 Deploy Preview https://deploy-preview-6351--rsbuild.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 67 (🔴 down 2 from production)
Accessibility: 97 (no change from production)
Best Practices: 100 (no change from production)
SEO: 100 (no change from production)
PWA: 60 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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

@chenjiahan chenjiahan merged commit bdd45cb into main Oct 13, 2025
12 checks passed
@chenjiahan chenjiahan deleted the build_stats_to_json_1013 branch October 13, 2025 05:29
@chenjiahan chenjiahan mentioned this pull request Oct 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant