@mui/internal-bundle-size-checker 1.1.1-canary.0 → 1.1.1-canary.10

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.
@@ -9,6 +9,7 @@ import { z } from 'zod/v4';
9
9
  export declare function ciReportUploadSchema(type: string, version: number, reportSchema: z.ZodType): z.ZodObject<{
10
10
  version: z.ZodLiteral<number>;
11
11
  timestamp: z.ZodNumber;
12
+ commitTimestamp: z.ZodOptional<z.ZodNumber>;
12
13
  commitSha: z.ZodString;
13
14
  repo: z.ZodString;
14
15
  reportType: z.ZodLiteral<string>;
@@ -19,6 +20,7 @@ export declare function ciReportUploadSchema(type: string, version: number, repo
19
20
  export declare const sizeSnapshotUploadSchema: z.ZodObject<{
20
21
  version: z.ZodLiteral<number>;
21
22
  timestamp: z.ZodNumber;
23
+ commitTimestamp: z.ZodOptional<z.ZodNumber>;
22
24
  commitSha: z.ZodString;
23
25
  repo: z.ZodString;
24
26
  reportType: z.ZodLiteral<string>;
@@ -0,0 +1,88 @@
1
+ export interface UploadConfig {
2
+ repo?: string;
3
+ branch?: string;
4
+ isPullRequest?: boolean;
5
+ apiUrl?: string;
6
+ }
7
+ export interface NormalizedUploadConfig {
8
+ repo: string;
9
+ branch: string;
10
+ isPullRequest: boolean;
11
+ prNumber?: string;
12
+ apiUrl: string;
13
+ }
14
+ export type StringEntry = string;
15
+ export interface ObjectEntry {
16
+ id: string;
17
+ code?: string;
18
+ import?: string;
19
+ importedNames?: string[];
20
+ externals?: string[];
21
+ track?: boolean;
22
+ expand?: boolean | {
23
+ exclude?: string[];
24
+ };
25
+ }
26
+ export type EntryPoint = StringEntry | ObjectEntry;
27
+ export interface BundleSizeCheckerConfigObject {
28
+ entrypoints: EntryPoint[];
29
+ upload?: UploadConfig | boolean | null;
30
+ comment?: boolean;
31
+ replace?: Record<string, string>;
32
+ }
33
+ export type BundleSizeCheckerConfig = BundleSizeCheckerConfigObject | Promise<BundleSizeCheckerConfigObject> | (() => BundleSizeCheckerConfigObject | Promise<BundleSizeCheckerConfigObject>);
34
+ export interface NormalizedBundleSizeCheckerConfig {
35
+ entrypoints: ObjectEntry[];
36
+ upload: NormalizedUploadConfig | null;
37
+ comment: boolean;
38
+ replace: Record<string, string>;
39
+ }
40
+ export interface CommandLineArgs {
41
+ analyze?: boolean;
42
+ output?: string;
43
+ verbose?: boolean;
44
+ filter?: string[];
45
+ concurrency?: number;
46
+ debug?: boolean;
47
+ }
48
+ export interface DiffCommandArgs {
49
+ base: string;
50
+ head?: string;
51
+ output?: 'json' | 'markdown';
52
+ reportUrl?: string;
53
+ }
54
+ export interface PrCommandArgs {
55
+ prNumber: number;
56
+ output?: 'json' | 'markdown';
57
+ }
58
+ export interface SizeSnapshotEntry {
59
+ parsed: number;
60
+ gzip: number;
61
+ }
62
+ export interface SizeInfo {
63
+ previous: number;
64
+ current: number;
65
+ absoluteDiff: number;
66
+ relativeDiff: number | null;
67
+ }
68
+ export interface Size {
69
+ id: string;
70
+ parsed: SizeInfo;
71
+ gzip: SizeInfo;
72
+ }
73
+ export interface ComparisonResult {
74
+ entries: Size[];
75
+ totals: {
76
+ totalParsed: number;
77
+ totalGzip: number;
78
+ totalParsedPercent: number;
79
+ totalGzipPercent: number;
80
+ };
81
+ fileCounts: {
82
+ added: number;
83
+ removed: number;
84
+ changed: number;
85
+ total: number;
86
+ };
87
+ }
88
+ export type SizeSnapshot = Record<string, SizeSnapshotEntry>;
@@ -1,4 +1,15 @@
1
1
  export type NormalizedUploadConfig = import('./types.js').NormalizedUploadConfig;
2
+ export type Commit = {
3
+ /**
4
+ * - The full commit SHA
5
+ */
6
+ sha: string;
7
+ /**
8
+ * - The commit's time in milliseconds, which orders it in the
9
+ * dashboard's timeline
10
+ */
11
+ timestamp: number;
12
+ };
2
13
  /**
3
14
  * Uploads the size snapshot to S3
4
15
  * @param {string} snapshotPath - The path to the size snapshot JSON file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/internal-bundle-size-checker",
3
- "version": "1.1.1-canary.0",
3
+ "version": "1.1.1-canary.10",
4
4
  "author": "MUI Team",
5
5
  "description": "Bundle size checker for MUI packages.",
6
6
  "license": "MIT",
@@ -29,23 +29,23 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@octokit/rest": "^22.0.1",
32
- "chalk": "^6.0.0",
32
+ "chalk": "^6.0.1",
33
33
  "env-ci": "^11.2.0",
34
- "execa": "^10.0.1",
34
+ "execa": "^10.2.1",
35
35
  "git-url-parse": "^16.1.0",
36
36
  "micromatch": "^4.0.8",
37
37
  "piscina": "^5.3.2",
38
- "rollup-plugin-visualizer": "^7.1.1",
39
- "vite": "^8.3.0",
40
- "yargs": "^18.1.0",
41
- "zod": "^4.6.4"
38
+ "rollup-plugin-visualizer": "^7.3.0",
39
+ "vite": "^8.4.0",
40
+ "yargs": "^18.2.0",
41
+ "zod": "^4.6.7"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@types/env-ci": "3.1.4",
45
45
  "@types/micromatch": "4.0.10",
46
46
  "@types/yargs": "17.0.35"
47
47
  },
48
- "gitSha": "764e3b3cfc14293e74e93f3413609025f502bab9",
48
+ "gitSha": "003bc3927b21f1caf942d94fec0f6e3caf21eeb0",
49
49
  "scripts": {
50
50
  "build": "tsc -p tsconfig.build.json",
51
51
  "test": "pnpm -w test --project @mui/internal-bundle-size-checker",
package/src/ciReport.js CHANGED
@@ -11,6 +11,8 @@ export function ciReportUploadSchema(type, version, reportSchema) {
11
11
  return z.object({
12
12
  version: z.literal(version),
13
13
  timestamp: z.number(),
14
+ /** When the commit was made, in milliseconds: what orders it in the dashboard's timeline. */
15
+ commitTimestamp: z.number().optional(),
14
16
  commitSha: z.string().regex(/^[0-9a-f]{40}$/, 'Must be a 40-character hex string'),
15
17
  repo: z.string().includes('/', 'Must be in owner/repo format'),
16
18
  reportType: z.literal(type),
@@ -6,12 +6,21 @@ import { execa } from 'execa';
6
6
  */
7
7
 
8
8
  /**
9
- * Gets the current Git commit SHA
10
- * @returns {Promise<string>} The current commit SHA
9
+ * @typedef {object} Commit
10
+ * @property {string} sha - The full commit SHA
11
+ * @property {number} timestamp - The commit's time in milliseconds, which orders it in the
12
+ * dashboard's timeline
11
13
  */
12
- async function getCurrentCommitSHA() {
13
- const { stdout } = await execa('git', ['rev-parse', 'HEAD']);
14
- return stdout.trim();
14
+
15
+ /**
16
+ * Looks up a commit's SHA and time.
17
+ * @param {string} ref - The commit, by SHA or any other revision
18
+ * @returns {Promise<Commit>}
19
+ */
20
+ async function getCommit(ref) {
21
+ const { stdout } = await execa('git', ['log', '-1', '--format=%H %ct', ref]);
22
+ const [sha, time] = stdout.trim().split(' ');
23
+ return { sha, timestamp: Number(time) * 1000 };
15
24
  }
16
25
 
17
26
  /**
@@ -19,15 +28,16 @@ async function getCurrentCommitSHA() {
19
28
  * @param {string} apiUrl - Base URL of the CI report API
20
29
  * @param {Buffer} fileContent - The file content to upload
21
30
  * @param {NormalizedUploadConfig} uploadConfig - The normalized upload configuration
22
- * @param {string} sha - The commit SHA
31
+ * @param {Commit} commit - The commit the snapshot is of
23
32
  * @returns {Promise<{key:string}>}
24
33
  */
25
- async function uploadViaApi(apiUrl, fileContent, uploadConfig, sha) {
34
+ async function uploadViaApi(apiUrl, fileContent, uploadConfig, commit) {
26
35
  /** @type {import('./ciReport.js').SizeSnapshotUpload} */
27
36
  const requestBody = {
28
37
  version: 1,
29
38
  timestamp: Date.now(),
30
- commitSha: sha,
39
+ commitTimestamp: commit.timestamp,
40
+ commitSha: commit.sha,
31
41
  repo: uploadConfig.repo,
32
42
  reportType: 'size-snapshot',
33
43
  branch: uploadConfig.branch,
@@ -71,10 +81,10 @@ async function uploadViaApi(apiUrl, fileContent, uploadConfig, sha) {
71
81
  */
72
82
  export async function uploadSnapshot(snapshotPath, uploadConfig, commitSha) {
73
83
  // Run git operations and file reading in parallel
74
- const [sha, fileContent] = await Promise.all([
75
- commitSha || getCurrentCommitSHA(),
84
+ const [commit, fileContent] = await Promise.all([
85
+ getCommit(commitSha || 'HEAD'),
76
86
  fs.promises.readFile(snapshotPath),
77
87
  ]);
78
88
 
79
- return uploadViaApi(uploadConfig.apiUrl, fileContent, uploadConfig, sha);
89
+ return uploadViaApi(uploadConfig.apiUrl, fileContent, uploadConfig, commit);
80
90
  }
package/.npmignore DELETED
@@ -1,2 +0,0 @@
1
- __fixtures__
2
- *.tsbuildinfo
File without changes