@mui/internal-bundle-size-checker 1.0.6-canary.1 → 1.0.6-canary.2
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 +2 -2
- package/src/viteBuilder.js +7 -3
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
|
+
"version": "1.0.6-canary.2",
|
|
4
4
|
"description": "Bundle size checker for MUI packages.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@types/webpack-bundle-analyzer": "^4.7.0",
|
|
49
49
|
"@types/yargs": "^17.0.33"
|
|
50
50
|
},
|
|
51
|
-
"gitSha": "
|
|
51
|
+
"gitSha": "6b3c21c8d98eaaaa66539704ffcfe6b10b49e29b",
|
|
52
52
|
"scripts": {
|
|
53
53
|
"typescript": "tsc -p tsconfig.json",
|
|
54
54
|
"test": "pnpm -w test --project @mui/internal-bundle-size-checker"
|
package/src/viteBuilder.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import fs from 'fs/promises';
|
|
3
|
-
import
|
|
3
|
+
import * as zlib from 'zlib';
|
|
4
|
+
import { promisify } from 'util';
|
|
4
5
|
import { build, transformWithEsbuild } from 'vite';
|
|
5
6
|
import { visualizer } from 'rollup-plugin-visualizer';
|
|
6
7
|
|
|
8
|
+
const gzipAsync = promisify(zlib.gzip);
|
|
9
|
+
|
|
7
10
|
const rootDir = process.cwd();
|
|
8
11
|
|
|
9
12
|
/**
|
|
@@ -199,11 +202,12 @@ async function processBundleSizes(outDir, entryName) {
|
|
|
199
202
|
|
|
200
203
|
// Calculate sizes
|
|
201
204
|
const parsed = Buffer.byteLength(fileContent);
|
|
202
|
-
const
|
|
205
|
+
const gzipBuffer = await gzipAsync(fileContent, { level: zlib.constants.Z_BEST_COMPRESSION });
|
|
206
|
+
const gzipSize = Buffer.byteLength(gzipBuffer);
|
|
203
207
|
|
|
204
208
|
// Use chunk key as the name, or fallback to entry name for main chunk
|
|
205
209
|
const chunkName = chunkKey === 'virtual:entry.tsx' ? entryName : chunkKey;
|
|
206
|
-
return /** @type {const} */ ([chunkName, { parsed, gzip }]);
|
|
210
|
+
return /** @type {const} */ ([chunkName, { parsed, gzip: gzipSize }]);
|
|
207
211
|
});
|
|
208
212
|
|
|
209
213
|
const chunkEntries = await Promise.all(chunkPromises);
|