@@ -69,13 +69,27 @@ async function run() {
69
69
removeCache ( )
70
70
}
71
71
}
72
-
72
+ /**
73
+ * Builds all the targets in parallel.
74
+ * @param {Array<string> } targets - An array of targets to build.
75
+ * @returns {Promise<void> } - A promise representing the build process.
76
+ */
73
77
async function buildAll ( targets ) {
74
78
await runParallel ( cpus ( ) . length , targets , build )
75
79
}
76
80
81
+ /**
82
+ * Runs iterator function in parallel.
83
+ * @template T - The type of items in the data source
84
+ * @param {number } maxConcurrency - The maximum concurrency.
85
+ * @param {Array<T> } source - The data source
86
+ * @param {(item: T) => Promise<void> } iteratorFn - The iteratorFn
87
+ * @returns {Promise<void[]> } - A Promise array containing all iteration results.
88
+ */
77
89
async function runParallel ( maxConcurrency , source , iteratorFn ) {
90
+ /**@type {Promise<void>[] } */
78
91
const ret = [ ]
92
+ /**@type {Promise<void>[] } */
79
93
const executing = [ ]
80
94
for ( const item of source ) {
81
95
const p = Promise . resolve ( ) . then ( ( ) => iteratorFn ( item ) )
@@ -91,7 +105,11 @@ async function runParallel(maxConcurrency, source, iteratorFn) {
91
105
}
92
106
return Promise . all ( ret )
93
107
}
94
-
108
+ /**
109
+ * Builds the target.
110
+ * @param {string } target - The target to build.
111
+ * @returns {Promise<void> } - A promise representing the build process.
112
+ */
95
113
async function build ( target ) {
96
114
const pkgDir = path . resolve ( `packages/${ target } ` )
97
115
const pkg = require ( `${ pkgDir } /package.json` )
@@ -128,6 +146,11 @@ async function build(target) {
128
146
{ stdio : 'inherit' }
129
147
)
130
148
}
149
+ /**
150
+ * Checks the sizes of all targets.
151
+ * @param {string[] } targets - The targets to check sizes for.
152
+ * @returns {void }
153
+ */
131
154
132
155
function checkAllSizes ( targets ) {
133
156
if ( devOnly || ( formats && ! formats . includes ( 'global' ) ) ) {
@@ -140,6 +163,11 @@ function checkAllSizes(targets) {
140
163
console . log ( )
141
164
}
142
165
166
+ /**
167
+ * Checks the size of a target.
168
+ * @param {string } target - The target to check the size for.
169
+ * @returns {void }
170
+ */
143
171
function checkSize ( target ) {
144
172
const pkgDir = path . resolve ( `packages/${ target } ` )
145
173
checkFileSize ( `${ pkgDir } /dist/${ target } .global.prod.js` )
@@ -148,6 +176,11 @@ function checkSize(target) {
148
176
}
149
177
}
150
178
179
+ /**
180
+ * Checks the file size.
181
+ * @param {string } filePath - The path of the file to check the size for.
182
+ * @returns {void }
183
+ */
151
184
function checkFileSize ( filePath ) {
152
185
if ( ! existsSync ( filePath ) ) {
153
186
return
0 commit comments