Skip to content

size analysis project - phase 2 #3610

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Aug 21, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/health-metrics-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ jobs:
- run: cp config/ci.config.json config/project.json
- run: yarn install
- run: yarn build

- name: Run health-metrics/modular-exports-binary-size test
run: yarn modular-export-size-report
- name: Run health-metrics/binary-size test
run: yarn size-report

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"prettier": "prettier --config .prettierrc --write '**/*.{ts,js}'",
"lint": "lerna run --scope @firebase/* --scope rxfire lint",
"size-report": "node scripts/report_binary_size.js",
"modular-export-size-report": "ts-node-script scripts/report_modular_export_binary_size.ts",
"api-report": "lerna run --scope @firebase/*-exp api-report",
"docgen:exp": "ts-node-script scripts/exp/docgen.ts",
"postinstall": "yarn --cwd repo-scripts/changelog-generator build",
Expand Down
67 changes: 66 additions & 1 deletion repo-scripts/size-analysis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@



## Commands To Run The Tool
## Command Line Interface

### Adhoc Support

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


## Use the Tool Programatically
### `async generateReportForModule(moduleLocation: string): Promise<Report>`
#### This function generates size analysis report for the given module specified by the `moduleLocation` argument.
#### `@param moduleLocation: an absolute path to location of a firebase module`
```
try {
const moduleLocation: string = "absoulte/path/to/firebase/module";
const report: Report = await generateReportForModule(moduleLocation);
console.log(report);


}catch (error) {


console.log(error);
}


```

### `async generateReportForModules(moduleLocations: string[]): Promise<Report[]>`
#### This function recursively generates a size analysis report for every module (and its submodules) listed in moduleLocations array
#### `@param moduleLocations: an array of strings where each is a path to location of a firebase module`

```
try {
const moduleLocations: string[] = ['...module1', '...module2'];
const reports: Report[] = await generateReportForModules(moduleLocations);
console.log(reports);


}catch (error) {


console.log(error);
}


```

### `async generateReport(name: string, dtsFile: string, bundleFile: string): Promise<Report>`
#### Use this function for adhoc analysis. This function generates a size analysis report from the given definition file.
#### `@param name: name to be displayed on the report`
#### `@param: dtsFile: absolute path to a definition file of interest.`
#### `@param bundleFile: absolute path to the bundle file of given definition file`


```
try {
const name: string = "adhoc";
const dtsFile: string = '.../index.d.ts';
const bundleFile: string = '.../index.esm2017.js';
const report: Report = await generateReport(name, dtsFile, bundleFile);
console.log(report);


}catch (error) {


console.log(error);
}


```

Loading