MCPcopy Create free account
hub / github.com/vercel/vercel / build

Function build

packages/next/src/index.ts:214–3006  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

212}
213
214export const build: BuildV2 = async buildOptions => {
215 let { workPath, repoRootPath } = buildOptions;
216 const builderSpan = buildOptions.span ?? new Span({ name: 'vc.builder' });
217
218 const {
219 files,
220 entrypoint,
221 config = {},
222 meta = {},
223 buildCallback,
224 } = buildOptions;
225
226 validateEntrypoint(entrypoint);
227
228 let entryDirectory = path.dirname(entrypoint);
229 let entryPath = path.join(workPath, entryDirectory);
230
231 // allow testing root directory setting with vercel.json
232 if (config.rootDirectory) {
233 repoRootPath = entryPath;
234 entryPath = path.join(entryPath, config.rootDirectory as string);
235 }
236 const outputDirectory = path.join('./', config.outputDirectory || '.next');
237 const dotNextStatic = path.join(entryPath, outputDirectory, 'static');
238 // TODO: remove after testing used for simulating root directory monorepo
239 // setting that can't be triggered with vercel.json
240 const baseDir = repoRootPath || workPath;
241
242 debug(
243 JSON.stringify(
244 {
245 repoRootPath,
246 baseDir,
247 workPath,
248 entryPath,
249 entryDirectory,
250 outputDirectory,
251 },
252 null,
253 2
254 )
255 );
256
257 const prefixedEnvs = getPrefixedEnvVars({
258 envPrefix: 'NEXT_PUBLIC_',
259 envs: process.env,
260 });
261
262 for (const [key, value] of Object.entries(prefixedEnvs)) {
263 process.env[key] = value;
264 }
265
266 await download(files, workPath, meta);
267
268 if (config.rootDirectory) {
269 // this must come after the download step since files outside
270 // the root directory will be excluded if we update workPath first.
271 // This should not be used when the actual root directory setting

Callers 4

index.test.jsFile · 0.50
index.test.jsFile · 0.50
index.test.jsFile · 0.50
buildTemplateFunction · 0.50

Calls 15

validateEntrypointFunction · 0.90
debugFunction · 0.90
getPrefixedEnvVarsFunction · 0.90
downloadFunction · 0.90
getNodeVersionFunction · 0.90
scanParentDirsFunction · 0.90
getEnvForPackageManagerFunction · 0.90
normalizePackageJsonFunction · 0.90
getScriptNameFunction · 0.90
detectPackageManagerFunction · 0.90
execCommandFunction · 0.90
runNpmInstallFunction · 0.90

Tested by

no test coverage detected