@mui/internal-bundle-size-checker 1.0.6-canary.3 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/internal-bundle-size-checker",
3
- "version": "1.0.6-canary.3",
3
+ "version": "1.0.6",
4
4
  "description": "Bundle size checker for MUI packages.",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -48,7 +48,6 @@
48
48
  "@types/webpack-bundle-analyzer": "^4.7.0",
49
49
  "@types/yargs": "^17.0.33"
50
50
  },
51
- "gitSha": "9a792343de89d69bb1ab0f03adde3350b70eef41",
52
51
  "scripts": {
53
52
  "typescript": "tsc -p tsconfig.json",
54
53
  "test": "pnpm -w test --project @mui/internal-bundle-size-checker"
@@ -69,51 +69,6 @@ function generateEmphasizedChange({ id: bundle, parsed, gzip }) {
69
69
  return `**${bundle}** **parsed:** ${changeParsed} **gzip:** ${changeGzip}`;
70
70
  }
71
71
 
72
- /**
73
- * @typedef {Object} ColumnDefinition
74
- * @property {string} field - The property key to extract from data objects
75
- * @property {string} [header] - Column header (defaults to field name)
76
- * @property {'left'|'center'|'right'} [align='left'] - Column alignment
77
- */
78
-
79
- /**
80
- * Formats data as a markdown table
81
- * @param {ColumnDefinition[]} columns - Column definitions
82
- * @param {Partial<Record<string, unknown>>[]} data - Array of data objects
83
- * @returns {string} Formatted markdown table
84
- */
85
- function formatMarkdownTable(columns, data) {
86
- let table = '';
87
-
88
- // Extract headers and alignments from column definitions
89
- const headers = columns.map((col) => col.header || col.field);
90
- const alignments = columns.map((col) => col.align || 'left');
91
-
92
- // Header row
93
- table += `| ${headers.join(' | ')} |\n`;
94
-
95
- // Separator row with alignment
96
- const separators = alignments.map((align) => {
97
- switch (align) {
98
- case 'center':
99
- return ':----------:';
100
- case 'right':
101
- return '----------:';
102
- default:
103
- return '----------';
104
- }
105
- });
106
- table += `|${separators.join('|')}|\n`;
107
-
108
- // Data rows
109
- data.forEach((row) => {
110
- const cells = columns.map((col) => row[col.field] ?? '');
111
- table += `| ${cells.join(' | ')} |\n`;
112
- });
113
-
114
- return table;
115
- }
116
-
117
72
  /**
118
73
  * Generates a Markdown report for bundle size changes
119
74
  * @param {ComparisonResult} comparison - Comparison result from calculateSizeDiff
@@ -137,20 +92,9 @@ export function renderMarkdownReportContent(
137
92
  }
138
93
  return trackedEntry;
139
94
  });
140
-
141
- markdownContent += formatMarkdownTable(
142
- [
143
- { field: 'id', header: 'Bundle' },
144
- { field: 'parsed', header: 'Parsed Size', align: 'right' },
145
- { field: 'gzip', header: 'Gzip Size', align: 'right' },
146
- ],
147
- trackedEntries.map(({ id, parsed, gzip }) => ({
148
- id,
149
- parsed: formatChange(parsed.absoluteDiff, parsed.relativeDiff),
150
- gzip: formatChange(gzip.absoluteDiff, gzip.relativeDiff),
151
- })),
152
- );
153
- markdownContent += '\n';
95
+ // Show all tracked bundles directly (including unchanged ones)
96
+ const trackedChanges = trackedEntries.map(generateEmphasizedChange);
97
+ markdownContent += `${trackedChanges.join('\n')}`;
154
98
  } else {
155
99
  markdownContent += `**Total Size Change:** ${formatChange(
156
100
  comparison.totals.totalParsed,
@@ -163,26 +107,26 @@ export function renderMarkdownReportContent(
163
107
  markdownContent += `Files: ${comparison.fileCounts.total} total (${
164
108
  comparison.fileCounts.added
165
109
  } added, ${comparison.fileCounts.removed} removed, ${comparison.fileCounts.changed} changed)\n\n`;
110
+ }
166
111
 
167
- // Show all entries in details section, not just changed ones
168
- // Filter out tracked bundles to avoid duplication
169
- const trackedIdSet = new Set(track);
170
- const detailsEntries = comparison.entries.filter((entry) => !trackedIdSet.has(entry.id));
171
-
172
- // Cap at maxDetailsLines bundles to avoid overly large reports
173
- const cappedEntries = detailsEntries.slice(0, maxDetailsLines);
174
- const hasMore = detailsEntries.length > maxDetailsLines;
175
-
176
- if (cappedEntries.length > 0) {
177
- const allChanges = cappedEntries.map(generateEmphasizedChange);
178
- const bundleWord = cappedEntries.length === 1 ? 'bundle' : 'bundles';
179
- const summaryText = hasMore
180
- ? `Show details for ${cappedEntries.length} more ${bundleWord} (${detailsEntries.length - maxDetailsLines} more not shown)`
181
- : `Show details for ${cappedEntries.length} more ${bundleWord}`;
182
- markdownContent += `<details>\n<summary>${summaryText}</summary>\n\n`;
183
- markdownContent += `${allChanges.join('\n')}\n\n`;
184
- markdownContent += `</details>`;
185
- }
112
+ // Show all entries in details section, not just changed ones
113
+ // Filter out tracked bundles to avoid duplication
114
+ const trackedIdSet = new Set(track);
115
+ const detailsEntries = comparison.entries.filter((entry) => !trackedIdSet.has(entry.id));
116
+
117
+ // Cap at maxDetailsLines bundles to avoid overly large reports
118
+ const cappedEntries = detailsEntries.slice(0, maxDetailsLines);
119
+ const hasMore = detailsEntries.length > maxDetailsLines;
120
+
121
+ if (cappedEntries.length > 0) {
122
+ const allChanges = cappedEntries.map(generateEmphasizedChange);
123
+ const bundleWord = cappedEntries.length === 1 ? 'bundle' : 'bundles';
124
+ const summaryText = hasMore
125
+ ? `Show details for ${cappedEntries.length} more ${bundleWord} (${detailsEntries.length - maxDetailsLines} more not shown)`
126
+ : `Show details for ${cappedEntries.length} more ${bundleWord}`;
127
+ markdownContent += `<details>\n<summary>${summaryText}</summary>\n\n`;
128
+ markdownContent += `${allChanges.join('\n')}\n\n`;
129
+ markdownContent += `</details>`;
186
130
  }
187
131
 
188
132
  return markdownContent;
@@ -323,12 +323,13 @@ describe('renderMarkdownReport', () => {
323
323
  });
324
324
 
325
325
  expect(result).toMatchInlineSnapshot(`
326
- "| Bundle | Parsed Size | Gzip Size |
327
- |----------|----------:|----------:|
328
- | @mui/material/Button/index.js | 🔺+400B<sup>(+2.67%)</sup> | 🔺+100B<sup>(+2.22%)</sup> |
329
- | @mui/material/TextField/index.js | 🔺+200B<sup>(+0.91%)</sup> | 🔺+100B<sup>(+1.54%)</sup> |
326
+ "**@mui/material/Button/index.js**&emsp;**parsed:** 🔺+400B<sup>(+2.67%)</sup> **gzip:** 🔺+100B<sup>(+2.22%)</sup>
327
+ **@mui/material/TextField/index.js**&emsp;**parsed:** 🔺+200B<sup>(+0.91%)</sup> **gzip:** 🔺+100B<sup>(+1.54%)</sup><details>
328
+ <summary>Show details for 1 more bundle</summary>
330
329
 
330
+ **@mui/icons-material/Add.js**&emsp;**parsed:** 🔺+100B<sup>(+10.00%)</sup> **gzip:** 🔺+50B<sup>(+16.67%)</sup>
331
331
 
332
+ </details>
332
333
 
333
334
  [Details of bundle changes](https://frontend-public.mui.com/size-comparison/mui/material-ui/diff?prNumber=42&baseRef=master&baseCommit=abc123&headCommit=def456)"
334
335
  `);
@@ -358,12 +359,13 @@ describe('renderMarkdownReport', () => {
358
359
  });
359
360
 
360
361
  expect(result).toMatchInlineSnapshot(`
361
- "| Bundle | Parsed Size | Gzip Size |
362
- |----------|----------:|----------:|
363
- | @mui/material/Button/index.js | 🔺+500B<sup>(+3.33%)</sup> | 🔺+150B<sup>(+3.33%)</sup> |
364
- | @mui/material/TextField/index.js | 🔺+300B<sup>(+1.36%)</sup> | 🔺+150B<sup>(+2.31%)</sup> |
362
+ "**@mui/material/Button/index.js**&emsp;**parsed:** 🔺+500B<sup>(+3.33%)</sup> **gzip:** 🔺+150B<sup>(+3.33%)</sup>
363
+ **@mui/material/TextField/index.js**&emsp;**parsed:** 🔺+300B<sup>(+1.36%)</sup> **gzip:** 🔺+150B<sup>(+2.31%)</sup><details>
364
+ <summary>Show details for 1 more bundle</summary>
365
365
 
366
+ **@mui/icons-material/Add.js**&emsp;**parsed:** 🔺+1KB<sup>(+100.00%)</sup> **gzip:** 🔺+300B<sup>(+100.00%)</sup>
366
367
 
368
+ </details>
367
369
 
368
370
  [Details of bundle changes](https://frontend-public.mui.com/size-comparison/mui/material-ui/diff?prNumber=42&baseRef=master&baseCommit=abc123&headCommit=def456)"
369
371
  `);
@@ -393,11 +395,13 @@ describe('renderMarkdownReport', () => {
393
395
  });
394
396
 
395
397
  expect(result).toMatchInlineSnapshot(`
396
- "| Bundle | Parsed Size | Gzip Size |
397
- |----------|----------:|----------:|
398
- | @mui/material/Button/index.js | 🔺+400B<sup>(+2.67%)</sup> | 🔺+100B<sup>(+2.22%)</sup> |
398
+ "**@mui/material/Button/index.js**&emsp;**parsed:** 🔺+400B<sup>(+2.67%)</sup> **gzip:** 🔺+100B<sup>(+2.22%)</sup><details>
399
+ <summary>Show details for 2 more bundles</summary>
399
400
 
401
+ **@mui/icons-material/Add.js**&emsp;**parsed:** 🔺+100B<sup>(+10.00%)</sup> **gzip:** 🔺+50B<sup>(+16.67%)</sup>
402
+ **@mui/icons-material/Delete.js**&emsp;**parsed:** 🔺+100B<sup>(+8.33%)</sup> **gzip:** 🔺+50B<sup>(+14.29%)</sup>
400
403
 
404
+ </details>
401
405
 
402
406
  [Details of bundle changes](https://frontend-public.mui.com/size-comparison/mui/material-ui/diff?prNumber=42&baseRef=master&baseCommit=abc123&headCommit=def456)"
403
407
  `);
@@ -427,12 +431,13 @@ describe('renderMarkdownReport', () => {
427
431
  });
428
432
 
429
433
  expect(result).toMatchInlineSnapshot(`
430
- "| Bundle | Parsed Size | Gzip Size |
431
- |----------|----------:|----------:|
432
- | @mui/material/Button/index.js | 0B<sup>(0.00%)</sup> | 0B<sup>(0.00%)</sup> |
433
- | @mui/material/TextField/index.js | 0B<sup>(0.00%)</sup> | 0B<sup>(0.00%)</sup> |
434
+ "**@mui/material/Button/index.js**&emsp;**parsed:** 0B<sup>(0.00%)</sup> **gzip:** 0B<sup>(0.00%)</sup>
435
+ **@mui/material/TextField/index.js**&emsp;**parsed:** 0B<sup>(0.00%)</sup> **gzip:** 0B<sup>(0.00%)</sup><details>
436
+ <summary>Show details for 1 more bundle</summary>
434
437
 
438
+ **@mui/material/Icon/index.js**&emsp;**parsed:** 🔺+100B<sup>(+1.25%)</sup> **gzip:** 🔺+50B<sup>(+2.00%)</sup>
435
439
 
440
+ </details>
436
441
 
437
442
  [Details of bundle changes](https://frontend-public.mui.com/size-comparison/mui/material-ui/diff?prNumber=42&baseRef=master&baseCommit=abc123&headCommit=def456)"
438
443
  `);
@@ -460,11 +465,12 @@ describe('renderMarkdownReport', () => {
460
465
  });
461
466
 
462
467
  expect(result).toMatchInlineSnapshot(`
463
- "| Bundle | Parsed Size | Gzip Size |
464
- |----------|----------:|----------:|
465
- | @mui/material/Button/index.js | 🔺+400B<sup>(+2.67%)</sup> | 🔺+100B<sup>(+2.22%)</sup> |
468
+ "**@mui/material/Button/index.js**&emsp;**parsed:** 🔺+400B<sup>(+2.67%)</sup> **gzip:** 🔺+100B<sup>(+2.22%)</sup><details>
469
+ <summary>Show details for 1 more bundle</summary>
466
470
 
471
+ **@mui/material/TextField/index.js**&emsp;**parsed:** 0B<sup>(0.00%)</sup> **gzip:** 0B<sup>(0.00%)</sup>
467
472
 
473
+ </details>
468
474
 
469
475
  [Details of bundle changes](https://frontend-public.mui.com/size-comparison/mui/material-ui/diff?prNumber=42&baseRef=master&baseCommit=abc123&headCommit=def456)"
470
476
  `);
@@ -1,12 +1,9 @@
1
1
  import path from 'path';
2
2
  import fs from 'fs/promises';
3
- import * as zlib from 'zlib';
4
- import { promisify } from 'util';
3
+ import { gzipSync } from 'zlib';
5
4
  import { build, transformWithEsbuild } from 'vite';
6
5
  import { visualizer } from 'rollup-plugin-visualizer';
7
6
 
8
- const gzipAsync = promisify(zlib.gzip);
9
-
10
7
  const rootDir = process.cwd();
11
8
 
12
9
  /**
@@ -202,12 +199,11 @@ async function processBundleSizes(outDir, entryName) {
202
199
 
203
200
  // Calculate sizes
204
201
  const parsed = Buffer.byteLength(fileContent);
205
- const gzipBuffer = await gzipAsync(fileContent, { level: zlib.constants.Z_BEST_COMPRESSION });
206
- const gzipSize = Buffer.byteLength(gzipBuffer);
202
+ const gzip = Buffer.byteLength(gzipSync(fileContent));
207
203
 
208
204
  // Use chunk key as the name, or fallback to entry name for main chunk
209
205
  const chunkName = chunkKey === 'virtual:entry.tsx' ? entryName : chunkKey;
210
- return /** @type {const} */ ([chunkName, { parsed, gzip: gzipSize }]);
206
+ return /** @type {const} */ ([chunkName, { parsed, gzip }]);
211
207
  });
212
208
 
213
209
  const chunkEntries = await Promise.all(chunkPromises);