Skip to content

chore: add a time-consuming log for building #8720

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

Closed
wants to merge 2 commits into from
Closed
Changes from all 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
13 changes: 9 additions & 4 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ run()
async function run() {
const removeCache = scanEnums()
try {
const startTime = performance.now()
const resolvedTargets = targets.length
? fuzzyMatchTarget(targets, buildAllMatching)
: allTargets
Expand All @@ -64,7 +65,11 @@ async function run() {
stdio: 'inherit'
}
)
console.log()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why here a empty console.log

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To have an extra blank line in pnpm run build --withTypes

}
console.log(
`build in ${((performance.now() - startTime) / 1000).toFixed(2)} s`
)
} finally {
removeCache()
}
Expand All @@ -76,15 +81,15 @@ async function buildAll(targets) {

async function runParallel(maxConcurrency, source, iteratorFn) {
const ret = []
const executing = []
const executing = new Set()
for (const item of source) {
const p = Promise.resolve().then(() => iteratorFn(item, source))
ret.push(p)

if (maxConcurrency <= source.length) {
const e = p.then(() => executing.splice(executing.indexOf(e), 1))
executing.push(e)
if (executing.length >= maxConcurrency) {
const e = p.then(() => executing.delete(e))
executing.add(e)
if (executing.size >= maxConcurrency) {
await Promise.race(executing)
}
}
Expand Down