MCPcopy
hub / github.com/vercel/next.js / nextBuildWorkflow

Function nextBuildWorkflow

scripts/devlow-bench.mjs:32–224  ·  scripts/devlow-bench.mjs::nextBuildWorkflow
(benchmarkName, benchDir, pages, enableTurbopackCache)

Source from the content-addressed store, hash-verified

30
31const nextBuildWorkflow =
32 (benchmarkName, benchDir, pages, enableTurbopackCache) =>
33 async ({ turbopack, page }) => {
34 const pageConfig =
35 typeof pages[page] === class="st">'string' ? { url: pages[page] } : pages[page]
36 const cleanupTasks = []
37 try {
38 const env = {
39 TURBO_CACHE: enableTurbopackCache ? class="st">'1' : class="st">'0',
40 PATH: process.env.PATH,
41 NODE: process.env.NODE,
42 HOSTNAME: process.env.HOSTNAME,
43 PWD: process.env.PWD,
44 NEXT_TRACE_UPLOAD_DISABLED: class="st">'true',
45 NEXT_PRIVATE_SKIP_CANARY_CHECK: class="st">'true',
46 class="cm">// Enable next.js test mode to get HMR events and silence canary only
47 __NEXT_TEST_MODE: class="st">'1',
48 }
49
50 const serverEnv = {
51 ...env,
52 PORT: class="st">'0',
53 }
54
55 const benchmarkDir = resolve(REPO_ROOT, class="st">'bench', benchDir)
56
57 class="cm">// cleanup .next directory to remove filesystem cache
58 await retry(() =>
59 rm(join(benchmarkDir, class="st">'.next'), { recursive: true, force: true })
60 )
61
62 await measureTime(class="st">'cleanup', {
63 scenario: benchmarkName,
64 props: { turbopack, page },
65 })
66
67 const buildArgs = [turbopack ? class="st">'build-turbopack' : class="st">'build-webpack']
68 let buildShell = command(class="st">'pnpm', buildArgs, {
69 cwd: benchmarkDir,
70 env,
71 })
72 await buildShell.ok()
73
74 await measureTime(class="st">'build', {
75 scenario: benchmarkName,
76 props: { turbopack, page },
77 })
78
79 class="cm">// startup browser
80 let session = await newBrowserSession({})
81 const closeSession = async () => {
82 if (session) {
83 await session.close()
84 session = null
85 }
86 }
87 cleanupTasks.push(closeSession)
88 await measureTime(class="st">'browser startup', {
89 props: { turbopack, page },

Callers 1

devlow-bench.mjsFile · 0.85

Calls 15

commandFunction · 0.90
newBrowserSessionFunction · 0.90
killShellFunction · 0.85
closeSessionFunction · 0.85
splitMethod · 0.80
retryFunction · 0.70
measureTimeFunction · 0.70
reportMeasurementFunction · 0.70
okMethod · 0.65
pushMethod · 0.65
waitForOutputMethod · 0.65
reportMemUsageMethod · 0.65

Tested by

no test coverage detected