Skip to content

perf: avoid reading asset content from file system#6747

Merged
chenjiahan merged 2 commits intomainfrom
file_content_fs_1210
Dec 10, 2025
Merged

perf: avoid reading asset content from file system#6747
chenjiahan merged 2 commits intomainfrom
file_content_fs_1210

Conversation

@chenjiahan
Copy link
Copy Markdown
Member

Summary

Avoid reading asset content from file system, use stats.compilation.assets[n].value() instead.

Before

Screenshot 2025-12-10 at 17 23 41

After

Screenshot 2025-12-10 at 17 39 51

Checklist

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

Copilot AI review requested due to automatic review settings December 10, 2025 09:53
@netlify
Copy link
Copy Markdown

netlify bot commented Dec 10, 2025

Deploy Preview for rsbuild ready!

Name Link
🔨 Latest commit 6ac7b78
🔍 Latest deploy log https://app.netlify.com/projects/rsbuild/deploys/6939544aa81bde0008b10e63
😎 Deploy Preview https://deploy-preview-6747--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 11 from production)
Accessibility: 100 (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
Copy Markdown
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 improves build performance by avoiding file system reads when calculating asset sizes. Instead of reading asset content from disk using fs.readFile(), it directly accesses asset content from the webpack/rspack compilation object using stats.compilation.assets[n].source().

Key Changes:

  • Replaced file system reads with in-memory asset access via compilation stats
  • Inlined PrintFileSizeAsset type definition (moved from helpers to config types)
  • Removed the now-unused getAssetsFromStats helper function

Reviewed changes

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

File Description
packages/core/src/types/config.ts Moved PrintFileSizeAsset type definition from helpers/stats.ts and added documentation
packages/core/src/server/middlewares.ts Simplified asset listing to use Object.keys() directly instead of the removed helper
packages/core/src/plugins/fileSize.ts Core change: uses value.source() to get asset content from memory instead of fs.readFile()
packages/core/src/helpers/stats.ts Removed RsbuildAsset type and getAssetsFromStats helper (no longer needed)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@chenjiahan chenjiahan merged commit fa30724 into main Dec 10, 2025
11 checks passed
@chenjiahan chenjiahan deleted the file_content_fs_1210 branch December 10, 2025 13:12
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.

2 participants