Skip to content

perf: speed up accessing stats info#6414

Merged
chenjiahan merged 1 commit intomainfrom
optimize_get_assets_1023
Oct 23, 2025
Merged

perf: speed up accessing stats info#6414
chenjiahan merged 1 commit intomainfrom
optimize_get_assets_1023

Conversation

@chenjiahan
Copy link
Member

@chenjiahan chenjiahan commented Oct 23, 2025

Summary

As Rsbuild only needs the name and size of the assets from the Rspack stats object, using compilation.assets is much faster than using the stats.toJson({ assets: true }).

Before

Screenshot 2025-10-23 at 14 31 56

After

Screenshot 2025-10-23 at 14 27 38

Checklist

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

Copilot AI review requested due to automatic review settings October 23, 2025 06:44
@netlify
Copy link

netlify bot commented Oct 23, 2025

Deploy Preview for rsbuild ready!

Name Link
🔨 Latest commit 87258ce
🔍 Latest deploy log https://app.netlify.com/projects/rsbuild/deploys/68f9ceb45705370008a11234
😎 Deploy Preview https://deploy-preview-6414--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: 65 (🟢 up 6 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 performance by directly accessing compilation.assets instead of calling stats.toJson({ assets: true }) to retrieve asset information, significantly reducing the time needed to gather stats data.

Key Changes:

  • Introduced a lightweight RsbuildAsset type containing only name and size properties
  • Modified getAssetsFromStats() to extract assets directly from compilation.assets
  • Removed assets from RsbuildStatsItem type and eliminated unnecessary stats options configuration

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/core/src/helpers/stats.ts Introduced RsbuildAsset type and refactored getAssetsFromStats() to access compilation.assets directly; removed build-specific stats options
packages/core/src/types/rsbuild.ts Removed 'assets' from RsbuildStatsItem type definition
packages/core/src/types/config.ts Replaced PrintFileSizeAsset type definition with reference to RsbuildAsset
packages/core/src/plugins/fileSize.ts Updated to use Rspack.Stats instead of RsbuildStatsItem; refactored to work with new RsbuildAsset type
packages/core/src/server/middlewares.ts Removed optional chaining operators for asset properties

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@chenjiahan chenjiahan merged commit 957877d into main Oct 23, 2025
13 checks passed
@chenjiahan chenjiahan deleted the optimize_get_assets_1023 branch October 23, 2025 06:54
@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