Skip to content

Commit e0e0e71

Browse files
ChumpChiefclaude
andauthored
chore(bundle-size-tools): drop unused/flawed legacy behaviors (#27242)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 085f51b commit e0e0e71

15 files changed

Lines changed: 68 additions & 330 deletions

File tree

build-tools/packages/build-cli/src/commands/generate/bundleSizeDiff.ts

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import path from "node:path";
88
import {
99
ADOSizeComparator,
1010
type BundleComparison,
11-
type BundleMetric,
1211
bundlesContainNoChanges,
1312
getAzureDevopsApi,
1413
} from "@fluidframework/bundle-size-tools";
@@ -33,10 +32,6 @@ const defaultLocalReportPath = "./artifacts/bundleAnalyzerJson";
3332
// artifact.
3433
const defaultOutputDir = "./artifacts/bundleSizeDiff";
3534

36-
// Any single non-total metric that grows by more than this threshold is considered a
37-
// regression.
38-
const sizeRegressionThresholdBytes = 5120;
39-
4035
// Output file names. Only one of these is present per run: `result.json` when the
4136
// comparison produced a meaningful result, or `error.json` when it did not. Consumers
4237
// use file existence as the success/failure discriminator without needing to parse JSON.
@@ -46,17 +41,14 @@ const errorFileName = "error.json";
4641
/**
4742
* Shape of the `result.json` file produced on a successful comparison, discriminated by
4843
* `kind`. On `"no-changes"`, the comparison ran and found no size deltas. On `"changes"`,
49-
* the comparison found size deltas; `comparison` holds the diff and `sizeRegressionDetected`
50-
* flags any non-total metric that grew past the threshold.
44+
* the comparison found size deltas and `comparison` holds the diff. The producer is
45+
* unopinionated about what constitutes a "regression" — consumers apply their own thresholds.
5146
*/
5247
type BundleSizeDiffResult = {
5348
prNumber: number;
5449
baseCommit: string;
5550
targetBranch: string;
56-
} & (
57-
| { kind: "no-changes" }
58-
| { kind: "changes"; sizeRegressionDetected: boolean; comparison: BundleComparison[] }
59-
);
51+
} & ({ kind: "no-changes" } | { kind: "changes"; comparison: BundleComparison[] });
6052

6153
/**
6254
* Shape of the `error.json` file produced when the command could not produce a comparison
@@ -70,18 +62,6 @@ interface BundleSizeDiffError {
7062
error: string;
7163
}
7264

73-
/**
74-
* Compute whether any bundle shows a metric growing by more than the regression threshold.
75-
*/
76-
function detectSizeRegression(comparison: BundleComparison[]): boolean {
77-
return comparison.some((bundle: BundleComparison) =>
78-
Object.values(bundle.commonBundleMetrics).some(
79-
({ baseline, compare }: { baseline: BundleMetric; compare: BundleMetric }) =>
80-
compare.parsedSize - baseline.parsedSize > sizeRegressionThresholdBytes,
81-
),
82-
);
83-
}
84-
8565
export default class GenerateBundleSizeDiff extends BaseCommand<
8666
typeof GenerateBundleSizeDiff
8767
> {
@@ -134,10 +114,8 @@ export default class GenerateBundleSizeDiff extends BaseCommand<
134114
adoConnection,
135115
localReportPath,
136116
targetBranch,
137-
undefined,
138-
ADOSizeComparator.naiveFallbackCommitGenerator,
139117
);
140-
const comparisonResult = await sizeComparator.getSizeComparison(false);
118+
const comparisonResult = await sizeComparator.getSizeComparison();
141119

142120
const resolvedOutputDir = path.resolve(process.cwd(), outputDir);
143121
await mkdir(resolvedOutputDir, { recursive: true });
@@ -183,12 +161,7 @@ export default class GenerateBundleSizeDiff extends BaseCommand<
183161
};
184162
const result: BundleSizeDiffResult = bundlesContainNoChanges(comparison)
185163
? { ...common, kind: "no-changes" }
186-
: {
187-
...common,
188-
kind: "changes",
189-
sizeRegressionDetected: detectSizeRegression(comparison),
190-
comparison,
191-
};
164+
: { ...common, kind: "changes", comparison };
192165

193166
await writeFile(resultPath, JSON.stringify(result, undefined, 2));
194167
this.info(`Wrote ${resultPath}`);

build-tools/packages/bundle-size-tools/api-report/bundle-size-tools.api.md

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -10,38 +10,15 @@ import type { Build } from 'azure-devops-node-api/interfaces/BuildInterfaces';
1010
import type { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
1111
import type JSZip from 'jszip';
1212
import { WebApi } from 'azure-devops-node-api';
13-
import type Webpack from 'webpack';
1413

1514
// @public (undocumented)
1615
export class ADOSizeComparator {
1716
constructor(
1817
adoConstants: IADOConstants,
1918
adoConnection: WebApi,
2019
localReportPath: string,
21-
targetBranch: string,
22-
adoBuildId: number | undefined,
23-
getFallbackCommit?: ((startingCommit: string) => Generator<string>) | undefined);
24-
getSizeComparison(tagWaiting: boolean): Promise<SizeComparison>;
25-
static naiveFallbackCommitGenerator(startingCommit: string): Generator<string>;
26-
}
27-
28-
// @public (undocumented)
29-
export interface BannedModule {
30-
moduleName: string;
31-
reason: string;
32-
}
33-
34-
// @public
35-
export class BannedModulesPlugin {
36-
constructor(options: BannedModulesPluginOptions);
37-
// (undocumented)
38-
apply(compiler: Webpack.Compiler): void;
39-
}
40-
41-
// @public (undocumented)
42-
export interface BannedModulesPluginOptions {
43-
// (undocumented)
44-
bannedModules: BannedModule[];
20+
targetBranch: string);
21+
getSizeComparison(): Promise<SizeComparison>;
4522
}
4623

4724
// @public
@@ -124,9 +101,6 @@ export interface GetBuildOptions {
124101
// @public
125102
export function getBuilds(adoConnection: WebApi, options: GetBuildOptions): Promise<Build[]>;
126103

127-
// @public
128-
export function getBuildTagForCommit(commitHash: string): string;
129-
130104
// @public
131105
export function getBundleSummariesFromAnalyzer(args: GetBundleSummariesFromAnalyzerArgs): Promise<BundleSummaries>;
132106

@@ -138,9 +112,6 @@ export interface GetBundleSummariesFromAnalyzerArgs {
138112
getAnalyzerJson: (relativePath: string) => Promise<BundleAnalyzerPlugin.JsonReport>;
139113
}
140114

141-
// @public (undocumented)
142-
export function getPriorCommit(baseCommit: string): string;
143-
144115
// @public
145116
export function getZipObjectFromArtifact(adoConnection: WebApi, projectName: string, buildNumber: number, artifactName: string): Promise<JSZip>;
146117

@@ -155,11 +126,7 @@ export interface IADOConstants {
155126
// (undocumented)
156127
orgUrl: string;
157128
// (undocumented)
158-
prBuildDefinitionId?: number;
159-
// (undocumented)
160129
projectName: string;
161-
// (undocumented)
162-
projectRepoGuid?: string;
163130
}
164131

165132
// @public

build-tools/packages/bundle-size-tools/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@
4242
"dependencies": {
4343
"azure-devops-node-api": "^11.2.0",
4444
"jszip": "^3.10.1",
45-
"typescript": "~5.4.5",
46-
"webpack": "^5.103.0"
45+
"typescript": "~5.4.5"
4746
},
4847
"devDependencies": {
4948
"@biomejs/biome": "~2.4.5",

0 commit comments

Comments
 (0)