Skip to content

feat: support the gzip in bundle analysis #1180

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 22, 2025
Merged

feat: support the gzip in bundle analysis #1180

merged 4 commits into from
Jul 22, 2025

Conversation

easy1090
Copy link
Contributor

@easy1090 easy1090 commented Jul 21, 2025

Summary

image image

This pull request introduces support for tracking the gzip-compressed size of assets and modules across various components of the codebase. The changes improve visualization, computation, and representation of gzip sizes in the treemap, asset details, and module size calculations.

Gzip Size Integration

Treemap Enhancements:

  • Added gzipSize as a property in the TreeNode type in TreeMap.tsx and updated the tooltip rendering logic to display gzip size alongside source and bundled sizes. [1] [2] [3]
  • Updated the TreeNode type in file.tsx and modified utility functions like buildTreemapData and sumDirValue to include gzip size calculations. [1] [2] [3]

Asset Details:

  • Introduced a GzippedSizeTag component to display gzip size in asset details with a tooltip explaining its significance.
  • Enhanced the AssetDetail component to include gzip size in the module size representation, with conditional rendering based on the availability of gzip size data. [1] [2]

Module Size Computation:

  • Added gzip size computation using gzipSync from node:zlib in getAssetsModulesData and transformAssetsModulesData functions in assetsModules.ts. [1] [2]
  • Updated the Module class in module.ts to compute gzip size dynamically from source or parsed source if not explicitly provided.

Configuration Updates

  • Changed the default configuration in config.ts to enable gzip size computation by default.

Type Updates

  • Extended the ModuleSize interface in module.ts to include an optional gzipSize property.

Related Links

#849
#534

Copy link

netlify bot commented Jul 21, 2025

Deploy Preview for rsdoctor ready!

Name Link
🔨 Latest commit 2e4603e
🔍 Latest deploy log https://app.netlify.com/projects/rsdoctor/deploys/687f5d1ff1e3010008f6ef0c
😎 Deploy Preview https://deploy-preview-1180--rsdoctor.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

@easy1090 easy1090 force-pushed the feat/gzip-treemap branch from e023dba to fc72031 Compare July 22, 2025 09:21
@easy1090 easy1090 changed the title optimize: the tree map feat: support the gzip in bundle analysis Jul 22, 2025
@easy1090 easy1090 merged commit ed35274 into main Jul 22, 2025
10 of 11 checks passed
@easy1090 easy1090 deleted the feat/gzip-treemap branch July 22, 2025 10:40
@@ -96,8 +104,21 @@ export function transformAssetsModulesData(
if (!moduleGraph) return;
Object.entries(parsedModulesData).forEach(([moduleId, parsedData]) => {
const module = moduleGraph.getModuleByWebpackId(moduleId ?? '');
// 计算 gzip size
Copy link
Member

Choose a reason for hiding this comment

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

Should use English

parsedData.content.length > 0
) {
const { gzipSync } = require('node:zlib');
gzipSize = gzipSync(parsedData.content, { level: 9 }).length;
Copy link
Member

Choose a reason for hiding this comment

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

level: 9 is slow, we can use 6 to align with the default behavior of most web servers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, it's changed on next mr

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.

3 participants