@mui/internal-bundle-size-checker 1.0.9-canary.9 → 1.0.9-canary.91

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.
Files changed (43) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +14 -2
  3. package/build/builder.d.ts +49 -0
  4. package/build/ciReport.d.ts +32 -0
  5. package/build/cli.d.ts +3 -0
  6. package/build/configLoader.d.ts +34 -0
  7. package/build/defineConfig.d.ts +12 -0
  8. package/build/findExportedPaths.d.ts +28 -0
  9. package/build/formatUtils.d.ts +6 -0
  10. package/build/git.d.ts +23 -0
  11. package/build/github.d.ts +2 -0
  12. package/build/index.d.ts +3 -0
  13. package/build/notifyPr.d.ts +12 -0
  14. package/build/strings.d.ts +23 -0
  15. package/build/syncPrComment.d.ts +13 -0
  16. package/build/uploadSnapshot.d.ts +11 -0
  17. package/build/worker.d.ts +15 -0
  18. package/package.json +28 -32
  19. package/src/{viteBuilder.js → builder.js} +108 -37
  20. package/src/ciReport.js +44 -0
  21. package/src/cli.js +87 -104
  22. package/src/configLoader.js +132 -45
  23. package/src/defineConfig.js +4 -0
  24. package/src/findExportedPaths.js +238 -0
  25. package/src/findExportedPaths.test.js +54 -0
  26. package/src/git.js +50 -0
  27. package/src/github.js +4 -1
  28. package/src/index.js +1 -10
  29. package/src/notifyPr.js +81 -0
  30. package/src/strings.js +38 -0
  31. package/src/syncPrComment.js +37 -0
  32. package/src/types.d.ts +53 -51
  33. package/src/uploadSnapshot.js +50 -56
  34. package/src/worker.js +18 -19
  35. package/tsconfig.build.json +15 -0
  36. package/tsconfig.json +2 -2
  37. package/src/browser.d.ts +0 -2
  38. package/src/browser.js +0 -2
  39. package/src/fetchSnapshot.js +0 -96
  40. package/src/renderMarkdownReport.js +0 -263
  41. package/src/renderMarkdownReport.test.js +0 -587
  42. package/src/sizeDiff.js +0 -199
  43. package/src/webpackBuilder.js +0 -267
package/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- The MIT License (MIT)
1
+ MIT License
2
2
 
3
3
  Copyright (c) 2019 Material-UI SAS
4
4
 
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
 
@@ -63,6 +66,15 @@ export default defineConfig(async () => {
63
66
  importedNames: ['Button'],
64
67
  // When externals is not specified, peer dependencies will be automatically excluded
65
68
  },
69
+ // Expand a package into one entry per export from its package.json.
70
+ // Wildcard subpath exports (e.g. `"./*"`) are expanded against the files
71
+ // present in the installed package directory.
72
+ { id: '@mui/material', expand: true },
73
+ // Expand with glob exclusions (matched against the export subpath, e.g. `styles/colors`)
74
+ {
75
+ id: '@mui/material',
76
+ expand: { exclude: ['styles/**', 'internal/*'] },
77
+ },
66
78
  // ...
67
79
  ],
68
80
  // Optional upload configuration
@@ -0,0 +1,49 @@
1
+ export type ObjectEntry = import('./types.js').ObjectEntry;
2
+ export type CommandLineArgs = import('./types.js').CommandLineArgs;
3
+ export type SizeSnapshotEntry = import('./types.js').SizeSnapshotEntry;
4
+ export type ManifestChunk = {
5
+ /**
6
+ * - Hashed filename of the chunk
7
+ */
8
+ file: string;
9
+ /**
10
+ * - Optional name of the chunk
11
+ */
12
+ name?: string;
13
+ /**
14
+ * - Original source path
15
+ */
16
+ src?: string;
17
+ /**
18
+ * - Associated CSS files
19
+ */
20
+ css?: string[];
21
+ /**
22
+ * - Indicates if this is an entry point
23
+ */
24
+ isEntry?: boolean;
25
+ /**
26
+ * - Indicates if this is a dynamic entry point
27
+ */
28
+ isDynamicEntry?: boolean;
29
+ /**
30
+ * - Imported chunk keys
31
+ */
32
+ imports?: string[];
33
+ /**
34
+ * - Dynamically imported chunk keys
35
+ */
36
+ dynamicImports?: string[];
37
+ };
38
+ export type Manifest = Record<string, ManifestChunk>;
39
+ /**
40
+ * Get sizes for a vite bundle
41
+ * @param {ObjectEntry} entry - The entry configuration
42
+ * @param {CommandLineArgs} args - Command line arguments
43
+ * @param {Record<string, string>} [replacements] - String replacements to apply
44
+ * @returns {Promise<{ sizes: Map<string, SizeSnapshotEntry>, treemapPath: string }>}
45
+ */
46
+ export declare function getBundleSizes(entry: ObjectEntry, args: CommandLineArgs, replacements?: Record<string, string>): Promise<{
47
+ sizes: Map<string, SizeSnapshotEntry>;
48
+ treemapPath: string;
49
+ }>;
@@ -0,0 +1,32 @@
1
+ import { z } from 'zod/v4';
2
+ /**
3
+ * Creates a CI report upload schema for a specific report type.
4
+ * Common fields (commitSha, repo, branch, prNumber) are shared across all report types.
5
+ * @param {string} type - The report type literal (e.g. 'size-snapshot')
6
+ * @param {number} version - The schema version number
7
+ * @param {z.ZodType} reportSchema - Zod schema for the report payload
8
+ */
9
+ export declare function ciReportUploadSchema(type: string, version: number, reportSchema: z.ZodType): z.ZodObject<{
10
+ version: z.ZodLiteral<number>;
11
+ timestamp: z.ZodNumber;
12
+ commitSha: z.ZodString;
13
+ repo: z.ZodString;
14
+ reportType: z.ZodLiteral<string>;
15
+ prNumber: z.ZodOptional<z.ZodNumber>;
16
+ branch: z.ZodString;
17
+ report: z.ZodType<any, any, z.core.$ZodTypeInternals<any, any>>;
18
+ }, z.core.$strip>;
19
+ export declare const sizeSnapshotUploadSchema: z.ZodObject<{
20
+ version: z.ZodLiteral<number>;
21
+ timestamp: z.ZodNumber;
22
+ commitSha: z.ZodString;
23
+ repo: z.ZodString;
24
+ reportType: z.ZodLiteral<string>;
25
+ prNumber: z.ZodOptional<z.ZodNumber>;
26
+ branch: z.ZodString;
27
+ report: z.ZodType<any, any, z.core.$ZodTypeInternals<any, any>>;
28
+ }, z.core.$strip>;
29
+ export type SizeSnapshotUpload = z.infer<typeof sizeSnapshotUploadSchema>;
30
+ /**
31
+ * @typedef {z.infer<typeof sizeSnapshotUploadSchema>} SizeSnapshotUpload
32
+ */
package/build/cli.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export type CommandLineArgs = import('./types.js').CommandLineArgs;
2
+ export type NormalizedBundleSizeCheckerConfig = import('./types.js').NormalizedBundleSizeCheckerConfig;
3
+ export type SizeSnapshotEntry = import('./types.js').SizeSnapshotEntry;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Utility to load the bundle-size-checker configuration
3
+ */
4
+ export type BundleSizeCheckerConfigObject = import('./types.js').BundleSizeCheckerConfigObject;
5
+ export type UploadConfig = import('./types.js').UploadConfig;
6
+ export type NormalizedUploadConfig = import('./types.js').NormalizedUploadConfig;
7
+ export type EntryPoint = import('./types.js').EntryPoint;
8
+ export type ObjectEntry = import('./types.js').ObjectEntry;
9
+ export type NormalizedBundleSizeCheckerConfig = import('./types.js').NormalizedBundleSizeCheckerConfig;
10
+ /**
11
+ * Validates and normalizes an upload configuration object
12
+ * @param {UploadConfig} uploadConfig - The upload configuration to normalize
13
+ * @param {Object} ciInfo - CI environment information
14
+ * @param {string} [ciInfo.branch] - Branch name from CI environment
15
+ * @param {boolean} [ciInfo.isPr] - Whether this is a pull request from CI environment
16
+ * @param {string} [ciInfo.prBranch] - PR branch name from CI environment
17
+ * @param {string} [ciInfo.slug] - Repository slug from CI environment
18
+ * @param {string} [ciInfo.pr] - Pull request number from CI environment
19
+ * @returns {NormalizedUploadConfig} - Normalized upload config
20
+ * @throws {Error} If required fields are missing
21
+ */
22
+ export declare function applyUploadConfigDefaults(uploadConfig: UploadConfig, ciInfo: {
23
+ branch?: string;
24
+ isPr?: boolean;
25
+ prBranch?: string;
26
+ slug?: string;
27
+ pr?: string;
28
+ }): NormalizedUploadConfig;
29
+ /**
30
+ * Attempts to load the config file from the given directory
31
+ * @param {string} rootDir - The directory to search for the config file
32
+ * @returns {Promise<NormalizedBundleSizeCheckerConfig>} A promise that resolves to the normalized config object
33
+ */
34
+ export declare function loadConfig(rootDir: string): Promise<NormalizedBundleSizeCheckerConfig>;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @typedef {import('./types.js').BundleSizeCheckerConfig} BundleSizeCheckerConfig
3
+ */
4
+ export type BundleSizeCheckerConfig = import('./types.js').BundleSizeCheckerConfig;
5
+ /**
6
+ * Define a configuration for the bundle size checker.
7
+ * This is just a pass-through function for better TypeScript typing.
8
+ *
9
+ * @param {BundleSizeCheckerConfig} config - Configuration object
10
+ * @returns {BundleSizeCheckerConfig} The configuration object
11
+ */
12
+ export default function defineConfig(config: BundleSizeCheckerConfig): BundleSizeCheckerConfig;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Resolves a package's subpath exports, expanding wildcard patterns (e.g. `./*`)
3
+ * against the files present in the package directory.
4
+ */
5
+ export type ExactExport = {
6
+ key: string;
7
+ isNull: boolean;
8
+ };
9
+ export type PatternExport = {
10
+ key: string;
11
+ prefix: string;
12
+ suffix: string;
13
+ base: number;
14
+ isNull: boolean;
15
+ target: string | undefined;
16
+ };
17
+ export type CollectedExports = {
18
+ exact: ExactExport[];
19
+ patterns: PatternExport[];
20
+ };
21
+ /**
22
+ * Reads a package's `exports` field and returns its concrete subpath export
23
+ * paths, expanding any wildcard subpath patterns (e.g. `./*`) against the
24
+ * files present in the package directory.
25
+ * @param {string} pkgJson - Path to the package's package.json
26
+ * @returns {Promise<string[]>}
27
+ */
28
+ export declare function findExportedPaths(pkgJson: string): Promise<string[]>;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Format utilities for consistent display of sizes and percentages
3
+ */
4
+ export declare const byteSizeFormatter: Intl.NumberFormat;
5
+ export declare const byteSizeChangeFormatter: Intl.NumberFormat;
6
+ export declare 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 declare 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 declare 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 declare function getCurrentRepoInfo(): Promise<{
21
+ owner: string | null;
22
+ name: string | null;
23
+ }>;
@@ -0,0 +1,2 @@
1
+ /** @type {import('@octokit/rest').Octokit} */
2
+ export declare const octokit: import('@octokit/rest').Octokit;
@@ -0,0 +1,3 @@
1
+ import defineConfig from './defineConfig.js';
2
+ import { loadConfig } from './configLoader.js';
3
+ export { defineConfig, loadConfig };
@@ -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 declare function notifyPr(repo: string, prNumber: number, id: string, content: string): Promise<void>;
@@ -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 declare function escapeFilename(input: string, replacement?: string): string;
@@ -0,0 +1,13 @@
1
+ export type SyncPrCommentResult = {
2
+ success: boolean;
3
+ skipped?: boolean;
4
+ };
5
+ /**
6
+ * @typedef {{ success: boolean, skipped?: boolean }} SyncPrCommentResult
7
+ */
8
+ /**
9
+ * Syncs a PR comment via the dashboard API.
10
+ * @param {string} repo - Repository in owner/repo format
11
+ * @returns {Promise<SyncPrCommentResult>}
12
+ */
13
+ export declare function syncPrComment(repo: string): Promise<SyncPrCommentResult>;
@@ -0,0 +1,11 @@
1
+ export type NormalizedUploadConfig = import('./types.js').NormalizedUploadConfig;
2
+ /**
3
+ * Uploads the size snapshot to S3
4
+ * @param {string} snapshotPath - The path to the size snapshot JSON file
5
+ * @param {NormalizedUploadConfig} uploadConfig - The normalized upload configuration
6
+ * @param {string} [commitSha] - Optional commit SHA (defaults to current Git HEAD)
7
+ * @returns {Promise<{key:string}>}
8
+ */
9
+ export declare function uploadSnapshot(snapshotPath: string, uploadConfig: NormalizedUploadConfig, commitSha?: string): Promise<{
10
+ key: string;
11
+ }>;
@@ -0,0 +1,15 @@
1
+ export type ObjectEntry = import('./types.js').ObjectEntry;
2
+ export type CommandLineArgs = import('./types.js').CommandLineArgs;
3
+ export type SizeSnapshotEntry = import('./types.js').SizeSnapshotEntry;
4
+ /**
5
+ * Get sizes for a bundle
6
+ * @param {{ entry: ObjectEntry, args: CommandLineArgs, index: number, total: number, replace?: Record<string, string> }} options
7
+ * @returns {Promise<Array<[string, SizeSnapshotEntry]>>}
8
+ */
9
+ export default function getSizes({ entry, args, index, total, replace }: {
10
+ entry: ObjectEntry;
11
+ args: CommandLineArgs;
12
+ index: number;
13
+ total: number;
14
+ replace?: Record<string, string>;
15
+ }): Promise<Array<[string, SizeSnapshotEntry]>>;
package/package.json CHANGED
@@ -1,9 +1,12 @@
1
1
  {
2
2
  "name": "@mui/internal-bundle-size-checker",
3
- "version": "1.0.9-canary.9",
3
+ "version": "1.0.9-canary.91",
4
+ "author": "MUI Team",
4
5
  "description": "Bundle size checker for MUI packages.",
6
+ "license": "MIT",
5
7
  "type": "module",
6
8
  "main": "./src/index.js",
9
+ "types": "./build/index.d.ts",
7
10
  "bin": {
8
11
  "bundle-size-checker": "./bin/bundle-size-checker.js"
9
12
  },
@@ -14,45 +17,38 @@
14
17
  },
15
18
  "sideEffects": false,
16
19
  "exports": {
17
- ".": "./src/index.js",
20
+ ".": {
21
+ "types": "./build/index.d.ts",
22
+ "default": "./src/index.js"
23
+ },
18
24
  "./package.json": "./package.json",
19
- "./browser": "./src/browser.js"
25
+ "./ciReport": {
26
+ "types": "./build/ciReport.d.ts",
27
+ "default": "./src/ciReport.js"
28
+ }
20
29
  },
21
30
  "dependencies": {
22
- "@aws-sdk/client-s3": "^3.515.0",
23
- "@aws-sdk/credential-providers": "^3.787.0",
24
- "@babel/core": "^7.27.4",
25
- "@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",
31
+ "@octokit/rest": "^22.0.1",
32
+ "chalk": "^6.0.0",
33
+ "env-ci": "^11.2.0",
34
+ "execa": "^10.0.1",
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.3.2",
38
+ "rollup-plugin-visualizer": "^7.1.1",
39
+ "vite": "^8.2.2",
40
+ "yargs": "^18.1.0",
41
+ "zod": "^4.5.4"
45
42
  },
46
43
  "devDependencies": {
47
- "@types/env-ci": "^3.1.4",
48
- "@types/micromatch": "^4.0.9",
49
- "@types/webpack": "^5.28.5",
50
- "@types/webpack-bundle-analyzer": "^4.7.0",
51
- "@types/yargs": "^17.0.33"
44
+ "@types/env-ci": "3.1.4",
45
+ "@types/micromatch": "4.0.10",
46
+ "@types/yargs": "17.0.35"
52
47
  },
53
- "gitSha": "d1f9b7ff904cc935b837819585f848788794501d",
48
+ "gitSha": "2a2c232ded2053934aa082b335952c525c6ea88c",
54
49
  "scripts": {
55
- "typescript": "tsc -p tsconfig.json",
56
- "test": "pnpm -w test --project @mui/internal-bundle-size-checker"
50
+ "build": "tsc -p tsconfig.build.json",
51
+ "test": "pnpm -w test --project @mui/internal-bundle-size-checker",
52
+ "typescript": "tsc -noEmit"
57
53
  }
58
54
  }