@@ -38,10 +38,10 @@ import { Report } from '../../scripts/size_report/report_binary_size';
38
38
*
39
39
* More details on how a test bundle is built can be found in `bundle-analysis.ts`.
40
40
*
41
- * @param { string } [ version] - If present, the SDK version to run measurement against
42
- * @returns { Promise<Report[]> } A list of bundle size measurements
41
+ * @param version - If present, the SDK version to run measurement against
42
+ * @returns A list of bundle size measurements
43
43
*/
44
- export async function generateReportForBundles ( version ?: string ) {
44
+ export async function generateReportForBundles ( version ?: string ) : Promise < Report [ ] > {
45
45
const definitionDir = `${ __dirname } /bundle-definitions` ;
46
46
const outputDir = tmp . dirSync ( ) . name ;
47
47
console . log ( `Bundle definitions are located at "${ definitionDir } ".` ) ;
@@ -95,7 +95,18 @@ function parseAnalysisOutput(product: string, output: string) {
95
95
const analyses = JSON . parse ( fs . readFileSync ( output , { encoding : 'utf-8' } ) ) ;
96
96
const results : Report [ ] = [ ] ;
97
97
for ( const analysis of analyses ) {
98
- const sdk = 'bundle' ;
98
+ // The API of the backend for persisting size measurements currently requires data to be
99
+ // organized strictly in the below json format:
100
+ //
101
+ // {
102
+ // sdk: <some-string>,
103
+ // type: <some-string>,
104
+ // value: <some-integer>
105
+ // }
106
+ //
107
+ // We are reusing this API here, although its semantics does not make sense in the context of
108
+ // bundle-analysis.
109
+ const sdk = 'bundle' ; // to accommodate above API syntax, can be any string
99
110
const value = analysis . results [ 0 ] . size ;
100
111
const type = `${ product } (${ analysis . name } )` ;
101
112
results . push ( { sdk, type, value } ) ;
0 commit comments