Skip to content

Commit 1508a0e

Browse files
authored
size analysis project - phase 2 (#3610)
* size analysis project phase 2 * point to prod version * addressed PR comments * addressed PR comments * removed try catch block * consolidate common methods * addressed PR comments * changed method signature * fixed lint errors * fixed lint errors
1 parent 8d3aca7 commit 1508a0e

13 files changed

+530
-275
lines changed

.github/workflows/health-metrics-test.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ jobs:
2222
- run: cp config/ci.config.json config/project.json
2323
- run: yarn install
2424
- run: yarn build
25-
2625
- name: Run health-metrics/binary-size test
2726
run: yarn size-report
27+
- name: Run health-metrics/modular-exports-binary-size test
28+
run: yarn modular-export-size-report
2829

2930
# TODO(yifany): Enable startup times testing on CI.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@
4646
"docgen": "yarn docgen:js; yarn docgen:node",
4747
"prettier": "prettier --config .prettierrc --write '**/*.{ts,js}'",
4848
"lint": "lerna run --scope @firebase/* --scope rxfire lint",
49-
"size-report": "node scripts/report_binary_size.js",
49+
"size-report": "ts-node-script scripts/size_report/report_binary_size.ts",
50+
"modular-export-size-report": "ts-node-script scripts/size_report/report_modular_export_binary_size.ts",
5051
"api-report": "lerna run --scope @firebase/*-exp api-report",
5152
"docgen:exp": "ts-node-script scripts/exp/docgen.ts",
5253
"postinstall": "yarn --cwd repo-scripts/changelog-generator build",

repo-scripts/size-analysis/README.md

+66-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212

1313

14-
## Commands To Run The Tool
14+
## Command Line Interface
1515

1616
### Adhoc Support
1717

@@ -26,3 +26,68 @@ $firebase-js-sdk/repo-scripts/size-analysis `ts-node-script analysis.ts --im "@
2626
$firebase-js-sdk/repo-scripts/size-analysis `ts-node-script analysis.ts -o <path to output DIRECTORY>`
2727

2828

29+
## Use the Tool Programatically
30+
### `async generateReportForModule(moduleLocation: string): Promise<Report>`
31+
#### This function generates size analysis report for the given module specified by the `moduleLocation` argument.
32+
#### `@param moduleLocation: an absolute path to location of a firebase module`
33+
```
34+
try {
35+
const moduleLocation: string = "absoulte/path/to/firebase/module";
36+
const report: Report = await generateReportForModule(moduleLocation);
37+
console.log(report);
38+
39+
40+
}catch (error) {
41+
42+
43+
console.log(error);
44+
}
45+
46+
47+
```
48+
49+
### `async generateReportForModules(moduleLocations: string[]): Promise<Report[]>`
50+
#### This function recursively generates a size analysis report for every module (and its submodules) listed in moduleLocations array
51+
#### `@param moduleLocations: an array of strings where each is a path to location of a firebase module`
52+
53+
```
54+
try {
55+
const moduleLocations: string[] = ['...module1', '...module2'];
56+
const reports: Report[] = await generateReportForModules(moduleLocations);
57+
console.log(reports);
58+
59+
60+
}catch (error) {
61+
62+
63+
console.log(error);
64+
}
65+
66+
67+
```
68+
69+
### `async generateReport(name: string, dtsFile: string, bundleFile: string): Promise<Report>`
70+
#### Use this function for adhoc analysis. This function generates a size analysis report from the given definition file.
71+
#### `@param name: name to be displayed on the report`
72+
#### `@param: dtsFile: absolute path to a definition file of interest.`
73+
#### `@param bundleFile: absolute path to the bundle file of given definition file`
74+
75+
76+
```
77+
try {
78+
const name: string = "adhoc";
79+
const dtsFile: string = '.../index.d.ts';
80+
const bundleFile: string = '.../index.esm2017.js';
81+
const report: Report = await generateReport(name, dtsFile, bundleFile);
82+
console.log(report);
83+
84+
85+
}catch (error) {
86+
87+
88+
console.log(error);
89+
}
90+
91+
92+
```
93+

0 commit comments

Comments
 (0)