-
-
Notifications
You must be signed in to change notification settings - Fork 88
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
Conversation
✅ Deploy Preview for rsdoctor ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
e023dba
to
fc72031
Compare
@@ -96,8 +104,21 @@ export function transformAssetsModulesData( | |||
if (!moduleGraph) return; | |||
Object.entries(parsedModulesData).forEach(([moduleId, parsedData]) => { | |||
const module = moduleGraph.getModuleByWebpackId(moduleId ?? ''); | |||
// 计算 gzip size |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
Summary
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:
gzipSize
as a property in theTreeNode
type inTreeMap.tsx
and updated the tooltip rendering logic to display gzip size alongside source and bundled sizes. [1] [2] [3]TreeNode
type infile.tsx
and modified utility functions likebuildTreemapData
andsumDirValue
to include gzip size calculations. [1] [2] [3]Asset Details:
GzippedSizeTag
component to display gzip size in asset details with a tooltip explaining its significance.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:
gzipSync
fromnode:zlib
ingetAssetsModulesData
andtransformAssetsModulesData
functions inassetsModules.ts
. [1] [2]Module
class inmodule.ts
to compute gzip size dynamically from source or parsed source if not explicitly provided.Configuration Updates
config.ts
to enable gzip size computation by default.Type Updates
ModuleSize
interface inmodule.ts
to include an optionalgzipSize
property.Related Links
#849
#534