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

Function getBuildMatches

packages/cli/src/util/dev/builder.ts:532–715  ·  view source on GitHub ↗
(
  vercelConfig: VercelConfig,
  cwd: string,
  devServer: DevServer,
  fileList: string[]
)

Source from the content-addressed store, hash-verified

530}
531
532export async function getBuildMatches(
533 vercelConfig: VercelConfig,
534 cwd: string,
535 devServer: DevServer,
536 fileList: string[]
537): Promise<BuildMatch[]> {
538 const matches: BuildMatch[] = [];
539
540 if (fileList.length === 0) {
541 // If there's no files in the cwd then we know there won't be any build
542 // matches, so bail eagerly, and avoid printing the "no matches" message.
543 return matches;
544 }
545
546 const noMatches: Builder[] = [];
547 const builds = vercelConfig.builds || [{ src: '**', use: '@vercel/static' }];
548 const builderSpecs = new Set(builds.map(b => b.use).filter(Boolean));
549 const buildersWithPkgs = await importBuilders(builderSpecs, cwd);
550
551 for (const buildConfig of builds) {
552 let { src = '**', use, config = {} } = buildConfig;
553
554 if (!use) {
555 continue;
556 }
557
558 if (src[0] === '/') {
559 // Remove a leading slash so that the globbing is relative to `cwd`
560 // instead of the root of the filesystem. This matches the behavior
561 // of Vercel deployments.
562 src = src.substring(1);
563 }
564 // FIXME: hono-cleanup - we need to specify a src that we know exists
565 // so the rest of the script doesn't choke on it. But the framework preset
566 // needs to `index.js` so the BOA entry is index.func. BuildResultV2 allows
567 // us to return a different value from what the preset provides, but we need
568 // to use BuildResultV3 so that we can run the dev server with the startDevServer
569 // function exported from backend frameworks.
570 if (isBackendFramework(buildConfig.config?.framework)) {
571 src = 'package.json';
572 }
573
574 // lambda function files are trimmed of their file extension
575 const mapToEntrypoint = new Map<string, string>();
576
577 // The Python builder handles entrypoint discovery itself via <detect>.
578 // We still need to match a real file so the dev server creates a BuildMatch,
579 // but we preserve the original src (e.g. "<detect>") as the entrypoint
580 // passed to startDevServer/build.
581 if (
582 buildConfig.config?.framework &&
583 isPythonFramework(buildConfig.config?.framework)
584 ) {
585 const originalSrc = src;
586 const pythonManifestFiles = [
587 'pyproject.toml',
588 'requirements.txt',
589 'Pipfile',

Callers 1

updateBuildMatchesMethod · 0.90

Calls 11

isBackendFrameworkFunction · 0.90
isPythonFrameworkFunction · 0.90
relativeFunction · 0.90
highlightFunction · 0.85
filterMethod · 0.80
testMethod · 0.80
printMethod · 0.80
pushMethod · 0.65
getMethod · 0.65
setMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected