@@ -8,7 +8,6 @@ import path from "node:path";
88import {
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.
3433const 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 */
5247type 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-
8565export 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 } ` ) ;
0 commit comments