Skip to content
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

Turbopack: limit build concurrency, show progress bar #62319

Merged
merged 3 commits into from
Feb 21, 2024
Merged
Changes from 1 commit
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
19 changes: 15 additions & 4 deletions packages/next/src/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1416,9 +1416,9 @@ export default async function build(
rewrites: emptyRewritesObjToBeImplemented,
})

const promises = []
const jobs: (() => Promise<any>)[] = []
for (const [page, route] of currentEntrypoints.page) {
promises.push(
jobs.push(() =>
handleRouteType({
dev,
page,
Expand All @@ -1434,7 +1434,7 @@ export default async function build(
}

for (const [page, route] of currentEntrypoints.app) {
promises.push(
jobs.push(() =>
handleRouteType({
page,
dev: false,
Expand All @@ -1448,14 +1448,25 @@ export default async function build(
)
}

promises.push(
jobs.push(() =>
handlePagesErrorRoute({
currentIssues,
entrypoints: currentEntrypoints,
manifestLoader,
rewrites: emptyRewritesObjToBeImplemented,
})
)
const promises = []
let i = 0
function nextJob(): Promise<void> | undefined {
if (i < jobs.length) {
return jobs[i++]().then(nextJob)
}
}
// Run 10 concurrently
for (; i < 10; i++) {
sokra marked this conversation as resolved.
Show resolved Hide resolved
promises.push(jobs[i]().then(nextJob))
}
await Promise.all(promises)

await manifestLoader.writeManifests({
Expand Down
Loading