@mui/internal-bundle-size-checker 1.0.9-canary.5 → 1.0.9-canary.50

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/README.md CHANGED
@@ -19,9 +19,12 @@ bundle-size-checker [options]
19
19
 
20
20
  Options:
21
21
 
22
- - `--analyze`: Creates a webpack-bundle-analyzer report for each bundle
23
- - `--accurateBundles`: Displays used bundles accurately at the cost of more CPU cycles
22
+ - `--analyze`: Creates a report for each bundle (using rollup-plugin-visualizer)
23
+ - `--debug`: Build with readable output (no name mangling or whitespace collapse, but still tree-shake)
24
+ - `--verbose`: Show more detailed information during compilation
24
25
  - `--output`, `-o`: Path to output the size snapshot JSON file
26
+ - `--filter`, `-F`: Filter entry points by glob pattern(s) applied to their IDs
27
+ - `--concurrency`, `-c`: Number of workers to use for parallel processing
25
28
 
26
29
  ### Configuration
27
30
 
@@ -0,0 +1,2 @@
1
+ export { calculateSizeDiff } from "./sizeDiff.js";
2
+ export { fetchSnapshot } from "./fetchSnapshot.js";
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Get sizes for a vite bundle
3
+ * @param {ObjectEntry} entry - The entry configuration
4
+ * @param {CommandLineArgs} args - Command line arguments
5
+ * @param {Record<string, string>} [replacements] - String replacements to apply
6
+ * @returns {Promise<{ sizes: Map<string, SizeSnapshotEntry>, treemapPath: string }>}
7
+ */
8
+ export function getBundleSizes(entry: ObjectEntry, args: CommandLineArgs, replacements?: Record<string, string>): Promise<{
9
+ sizes: Map<string, SizeSnapshotEntry>;
10
+ treemapPath: string;
11
+ }>;
12
+ export type ManifestChunk = {
13
+ /**
14
+ * - Hashed filename of the chunk
15
+ */
16
+ file: string;
17
+ /**
18
+ * - Optional name of the chunk
19
+ */
20
+ name?: string | undefined;
21
+ /**
22
+ * - Original source path
23
+ */
24
+ src?: string | undefined;
25
+ /**
26
+ * - Associated CSS files
27
+ */
28
+ css?: string[] | undefined;
29
+ /**
30
+ * - Indicates if this is an entry point
31
+ */
32
+ isEntry?: boolean | undefined;
33
+ /**
34
+ * - Indicates if this is a dynamic entry point
35
+ */
36
+ isDynamicEntry?: boolean | undefined;
37
+ /**
38
+ * - Imported chunk keys
39
+ */
40
+ imports?: string[] | undefined;
41
+ /**
42
+ * - Dynamically imported chunk keys
43
+ */
44
+ dynamicImports?: string[] | undefined;
45
+ };
46
+ export type Manifest = Record<string, ManifestChunk>;
package/build/cli.d.ts ADDED
@@ -0,0 +1 @@
1
+ export type SizeSnapshot = import("./sizeDiff.js").SizeSnapshot;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Validates and normalizes an upload configuration object
3
+ * @param {UploadConfig} uploadConfig - The upload configuration to normalize
4
+ * @param {Object} ciInfo - CI environment information
5
+ * @param {string} [ciInfo.branch] - Branch name from CI environment
6
+ * @param {boolean} [ciInfo.isPr] - Whether this is a pull request from CI environment
7
+ * @param {string} [ciInfo.prBranch] - PR branch name from CI environment
8
+ * @param {string} [ciInfo.slug] - Repository slug from CI environment
9
+ * @returns {NormalizedUploadConfig} - Normalized upload config
10
+ * @throws {Error} If required fields are missing
11
+ */
12
+ export function applyUploadConfigDefaults(uploadConfig: UploadConfig, ciInfo: {
13
+ branch?: string | undefined;
14
+ isPr?: boolean | undefined;
15
+ prBranch?: string | undefined;
16
+ slug?: string | undefined;
17
+ }): NormalizedUploadConfig;
18
+ /**
19
+ * Attempts to load the config file from the given directory
20
+ * @param {string} rootDir - The directory to search for the config file
21
+ * @returns {Promise<NormalizedBundleSizeCheckerConfig>} A promise that resolves to the normalized config object
22
+ */
23
+ export function loadConfig(rootDir: string): Promise<NormalizedBundleSizeCheckerConfig>;
@@ -0,0 +1 @@
1
+ export const DASHBOARD_ORIGIN: "https://frontend-public.mui.com";
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Define a configuration for the bundle size checker.
3
+ * This is just a pass-through function for better TypeScript typing.
4
+ *
5
+ * @param {BundleSizeCheckerConfig} config - Configuration object
6
+ * @returns {BundleSizeCheckerConfig} The configuration object
7
+ */
8
+ export default function defineConfig(config: BundleSizeCheckerConfig): BundleSizeCheckerConfig;
@@ -0,0 +1,7 @@
1
+ /**
2
+ *
3
+ * @param {string} repo - The name of the repository e.g. 'mui/material-ui'
4
+ * @param {string} sha - The commit SHA
5
+ * @returns {Promise<import('./sizeDiff.js').SizeSnapshot>} - The size snapshot data
6
+ */
7
+ export function fetchSnapshot(repo: string, sha: string): Promise<import("./sizeDiff.js").SizeSnapshot>;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Attempts to fetch a snapshot with fallback to parent commits
3
+ * @param {string} repo - Repository name
4
+ * @param {string} commit - The commit SHA to start from
5
+ * @param {number} [fallbackDepth=3] - How many parent commits to try as fallback
6
+ * @returns {Promise<{snapshot: import('./sizeDiff.js').SizeSnapshot | null, actualCommit: string | null}>}
7
+ */
8
+ export function fetchSnapshotWithFallback(repo: string, commit: string, fallbackDepth?: number): Promise<{
9
+ snapshot: import("./sizeDiff.js").SizeSnapshot | null;
10
+ actualCommit: string | null;
11
+ }>;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Format utilities for consistent display of sizes and percentages
3
+ */
4
+ export const byteSizeFormatter: Intl.NumberFormat;
5
+ export const byteSizeChangeFormatter: Intl.NumberFormat;
6
+ export const displayPercentFormatter: Intl.NumberFormat;
package/build/git.d.ts ADDED
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Gets parent commits for a given commit SHA using git CLI
3
+ * @param {string} repo - Repository name (e.g., 'mui/material-ui') - ignored for git CLI
4
+ * @param {string} commit - The commit SHA to start from
5
+ * @param {number} depth - How many commits to retrieve (including the starting commit)
6
+ * @returns {Promise<string[]>} Array of commit SHAs in chronological order (excluding the starting commit)
7
+ */
8
+ export function getParentCommits(repo: string, commit: string, depth?: number): Promise<string[]>;
9
+ /**
10
+ * Compares two commits and returns merge base information using git CLI
11
+ * @param {string} base - Base commit SHA
12
+ * @param {string} head - Head commit SHA
13
+ * @returns {Promise<string>} Object with merge base commit info
14
+ */
15
+ export function getMergeBase(base: string, head: string): Promise<string>;
16
+ /**
17
+ * Gets the current repository owner and name from git remote
18
+ * @returns {Promise<{owner: string | null, name: string | null}>}
19
+ */
20
+ export function getCurrentRepoInfo(): Promise<{
21
+ owner: string | null;
22
+ name: string | null;
23
+ }>;
@@ -0,0 +1,2 @@
1
+ /** @type {import('@octokit/rest').Octokit} */
2
+ export const octokit: import("@octokit/rest").Octokit;
@@ -0,0 +1,4 @@
1
+ import defineConfig from './defineConfig.js';
2
+ import { loadConfig } from './configLoader.js';
3
+ import { renderMarkdownReport } from './renderMarkdownReport.js';
4
+ export { defineConfig, loadConfig, renderMarkdownReport };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Creates or updates a comment on a pull request with the specified content.
3
+ * Uses an HTML comment marker to identify and update existing comments.
4
+ * Searches page-by-page (newest first) and stops early when comment is found.
5
+ *
6
+ * @param {string} repo - The repository in format "owner/repo"
7
+ * @param {number} prNumber - The pull request number
8
+ * @param {string} id - Unique identifier to mark the comment for future updates
9
+ * @param {string} content - The content to post or update in the comment
10
+ * @returns {Promise<void>}
11
+ */
12
+ export function notifyPr(repo: string, prNumber: number, id: string, content: string): Promise<void>;
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Generates a Markdown report for bundle size changes
3
+ * @param {ComparisonResult} comparison - Comparison result from calculateSizeDiff
4
+ * @param {Object} [options] - Additional options
5
+ * @param {string[]} [options.track] - Array of bundle IDs to track. If specified, totals will only include tracked bundles and all tracked bundles will be shown prominently
6
+ * @param {number} [options.maxDetailsLines=100] - Maximum number of bundles to show in details section
7
+ * @returns {string} Markdown report
8
+ */
9
+ export function renderMarkdownReportContent(comparison: ComparisonResult, { track, maxDetailsLines }?: {
10
+ track?: string[] | undefined;
11
+ maxDetailsLines?: number | undefined;
12
+ }): string;
13
+ /**
14
+ *
15
+ * @param {PrInfo} prInfo
16
+ * @param {Object} [options] - Additional options
17
+ * @param {string[]} [options.track] - Array of bundle IDs to track
18
+ * @param {number} [options.fallbackDepth=3] - How many parent commits to try as fallback when base snapshot is missing
19
+ * @param {number} [options.maxDetailsLines=100] - Maximum number of bundles to show in details section
20
+ * @param {(base: string, head: string) => Promise<string>} [options.getMergeBase] - Custom function to get merge base commit
21
+ * @returns {Promise<string>} Markdown report
22
+ */
23
+ export function renderMarkdownReport(prInfo: PrInfo, options?: {
24
+ track?: string[] | undefined;
25
+ fallbackDepth?: number | undefined;
26
+ maxDetailsLines?: number | undefined;
27
+ getMergeBase?: ((base: string, head: string) => Promise<string>) | undefined;
28
+ }): Promise<string>;
29
+ export type ColumnDefinition = {
30
+ /**
31
+ * - The property key to extract from data objects
32
+ */
33
+ field: string;
34
+ /**
35
+ * - Column header (defaults to field name)
36
+ */
37
+ header?: string | undefined;
38
+ /**
39
+ * - Column alignment
40
+ */
41
+ align?: "left" | "right" | "center" | undefined;
42
+ };
43
+ export type Size = import("./sizeDiff.js").Size;
44
+ export type SizeSnapshot = import("./sizeDiff.js").SizeSnapshot;
45
+ export type ComparisonResult = import("./sizeDiff.js").ComparisonResult;
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Calculates size difference between two snapshots
3
+ *
4
+ * @param {SizeSnapshot} baseSnapshot - Base snapshot (previous)
5
+ * @param {SizeSnapshot} targetSnapshot - Target snapshot (current)
6
+ * @returns {ComparisonResult} Comparison result with entries, totals, and file counts
7
+ */
8
+ export function calculateSizeDiff(baseSnapshot: SizeSnapshot, targetSnapshot: SizeSnapshot): ComparisonResult;
9
+ export type SizeSnapshot = {
10
+ [x: string]: SizeSnapshotEntry;
11
+ };
12
+ export type Size = {
13
+ /**
14
+ * - Bundle identifier
15
+ */
16
+ id: string;
17
+ /**
18
+ * - Parsed size information
19
+ */
20
+ parsed: {
21
+ previous: number;
22
+ current: number;
23
+ absoluteDiff: number;
24
+ relativeDiff: number | null;
25
+ };
26
+ /**
27
+ * - Gzipped size information
28
+ */
29
+ gzip: {
30
+ previous: number;
31
+ current: number;
32
+ absoluteDiff: number;
33
+ relativeDiff: number | null;
34
+ };
35
+ };
36
+ export type ComparisonResult = {
37
+ /**
38
+ * - Size entries for each bundle
39
+ */
40
+ entries: Size[];
41
+ /**
42
+ * - Total size information
43
+ */
44
+ totals: {
45
+ totalParsed: number;
46
+ totalGzip: number;
47
+ totalParsedPercent: number;
48
+ totalGzipPercent: number;
49
+ };
50
+ /**
51
+ * - File count information
52
+ */
53
+ fileCounts: {
54
+ added: number;
55
+ removed: number;
56
+ changed: number;
57
+ total: number;
58
+ };
59
+ };
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Inspired by https://github.com/parshap/node-sanitize-filename
3
+ *
4
+ * Replaces characters in strings that are illegal/unsafe for filenames.
5
+ * Unsafe characters are either removed or replaced by a substitute set
6
+ * in the optional `options` object.
7
+ *
8
+ * Illegal Characters on Various Operating Systems
9
+ * / ? < > \ : * | "
10
+ * https://kb.acronis.com/content/39790
11
+ *
12
+ * Unicode Control codes
13
+ * C0 0x00-0x1f & C1 (0x80-0x9f)
14
+ * http://en.wikipedia.org/wiki/C0_and_C1_control_codes
15
+ *
16
+ * Reserved filenames on Unix-based systems (".", "..")
17
+ * Reserved filenames in Windows ("CON", "PRN", "AUX", "NUL", "COM1",
18
+ * "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9",
19
+ * "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", and
20
+ * "LPT9") case-insesitively and with or without filename extensions.
21
+ * @param {string} input
22
+ */
23
+ export function escapeFilename(input: string, replacement?: string): string;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Uploads the size snapshot to S3
3
+ * @param {string} snapshotPath - The path to the size snapshot JSON file
4
+ * @param {NormalizedUploadConfig} uploadConfig - The normalized upload configuration
5
+ * @param {string} [commitSha] - Optional commit SHA (defaults to current Git HEAD)
6
+ * @returns {Promise<{key:string}>}
7
+ */
8
+ export function uploadSnapshot(snapshotPath: string, uploadConfig: NormalizedUploadConfig, commitSha?: string): Promise<{
9
+ key: string;
10
+ }>;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Get sizes for a bundle
3
+ * @param {{ entry: ObjectEntry, args: CommandLineArgs, index: number, total: number, replace?: Record<string, string> }} options
4
+ * @returns {Promise<Array<[string, SizeSnapshotEntry]>>}
5
+ */
6
+ export default function getSizes({ entry, args, index, total, replace }: {
7
+ entry: ObjectEntry;
8
+ args: CommandLineArgs;
9
+ index: number;
10
+ total: number;
11
+ replace?: Record<string, string>;
12
+ }): Promise<Array<[string, SizeSnapshotEntry]>>;
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@mui/internal-bundle-size-checker",
3
- "version": "1.0.9-canary.5",
3
+ "version": "1.0.9-canary.50",
4
4
  "description": "Bundle size checker for MUI packages.",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
7
+ "types": "./build/index.d.ts",
7
8
  "bin": {
8
9
  "bundle-size-checker": "./bin/bundle-size-checker.js"
9
10
  },
@@ -14,45 +15,38 @@
14
15
  },
15
16
  "sideEffects": false,
16
17
  "exports": {
17
- ".": "./src/index.js",
18
+ ".": {
19
+ "types": "./build/index.d.ts",
20
+ "default": "./src/index.js"
21
+ },
18
22
  "./package.json": "./package.json",
19
- "./browser": "./src/browser.js"
23
+ "./browser": {
24
+ "types": "./build/browser.d.ts",
25
+ "default": "./src/browser.js"
26
+ }
20
27
  },
21
28
  "dependencies": {
22
- "@aws-sdk/client-s3": "^3.515.0",
23
- "@aws-sdk/credential-providers": "^3.787.0",
24
- "@babel/core": "^7.27.4",
29
+ "@aws-sdk/client-s3": "^3.901.0",
30
+ "@aws-sdk/credential-providers": "^3.901.0",
25
31
  "@octokit/rest": "^22.0.0",
26
- "@babel/preset-react": "^7.18.6",
27
- "@babel/preset-typescript": "^7.27.1",
28
- "babel-loader": "^10.0.0",
29
- "chalk": "^5.4.1",
30
- "compression-webpack-plugin": "^10.0.0",
31
- "css-loader": "^7.1.2",
32
- "env-ci": "^11.1.0",
33
- "execa": "^7.2.0",
34
- "fast-glob": "^3.3.2",
35
- "file-loader": "^6.2.0",
32
+ "chalk": "^5.6.2",
33
+ "env-ci": "^11.2.0",
34
+ "execa": "^9.6.0",
36
35
  "git-url-parse": "^16.1.0",
37
36
  "micromatch": "^4.0.8",
38
- "piscina": "^4.2.1",
39
- "rollup-plugin-visualizer": "^6.0.1",
40
- "terser-webpack-plugin": "^5.3.10",
41
- "vite": "^6.3.5",
42
- "webpack": "^5.90.3",
43
- "webpack-bundle-analyzer": "^4.10.1",
44
- "yargs": "^17.7.2"
37
+ "piscina": "^5.1.3",
38
+ "rollup-plugin-visualizer": "^6.0.4",
39
+ "vite": "^7.1.9",
40
+ "yargs": "^18.0.0"
45
41
  },
46
42
  "devDependencies": {
47
43
  "@types/env-ci": "^3.1.4",
48
44
  "@types/micromatch": "^4.0.9",
49
- "@types/webpack": "^5.28.5",
50
- "@types/webpack-bundle-analyzer": "^4.7.0",
51
45
  "@types/yargs": "^17.0.33"
52
46
  },
53
- "gitSha": "8ddf4c81e7d28c0a1b0aa151d76697873870f123",
47
+ "gitSha": "fa6637adec099d6853ce0526bcb030b1d68907a5",
54
48
  "scripts": {
55
- "typescript": "tsc -p tsconfig.json",
49
+ "build": "tsc -p tsconfig.build.json",
56
50
  "test": "pnpm -w test --project @mui/internal-bundle-size-checker"
57
51
  }
58
52
  }