11
11
12
12
13
13
14
- ## Commands To Run The Tool
14
+ ## Command Line Interface
15
15
16
16
### Adhoc Support
17
17
@@ -26,3 +26,68 @@ $firebase-js-sdk/repo-scripts/size-analysis `ts-node-script analysis.ts --im "@
26
26
$firebase-js-sdk/repo-scripts/size-analysis ` ts-node-script analysis.ts -o <path to output DIRECTORY> `
27
27
28
28
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