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

Method triggerBuild

packages/cli/src/util/dev/server.ts:1664–1721  ·  view source on GitHub ↗
(
    match: BuildMatch,
    requestPath: string | null,
    req: http.IncomingMessage | null,
    vercelConfig: VercelConfig,
    previousBuildResult?: BuildResult,
    filesChanged?: string[],
    filesRemoved?: string[]
  )

Source from the content-addressed store, hash-verified

1662 }
1663
1664 async triggerBuild(
1665 match: BuildMatch,
1666 requestPath: string | null,
1667 req: http.IncomingMessage | null,
1668 vercelConfig: VercelConfig,
1669 previousBuildResult?: BuildResult,
1670 filesChanged?: string[],
1671 filesRemoved?: string[]
1672 ) {
1673 // If the requested asset wasn't found in the match's
1674 // outputs then trigger a build
1675 const buildKey =
1676 requestPath === null
1677 ? match.entrypoint
1678 : `${match.entrypoint}-${requestPath}`;
1679 let buildPromise = this.inProgressBuilds.get(buildKey);
1680 if (buildPromise) {
1681 // A build for `buildKey` is already in progress, so don't trigger
1682 // another rebuild for this request - just wait on the existing one.
1683 let msg = `De-duping build "${buildKey}"`;
1684 if (req) {
1685 msg += ` for "${req.method} ${req.url}"`;
1686 }
1687 output.debug(msg);
1688 } else {
1689 if (previousBuildResult) {
1690 // Tear down any `output` assets from a previous build, so that they
1691 // are not available to be served while the rebuild is in progress.
1692 for (const [name] of Object.entries(previousBuildResult.output)) {
1693 output.debug(`Removing asset "${name}"`);
1694 delete match.buildOutput[name];
1695 // TODO: shut down Lambda instance
1696 }
1697 }
1698 let msg = `Building asset "${buildKey}"`;
1699 if (req) {
1700 msg += ` for "${req.method} ${req.url}"`;
1701 }
1702 output.debug(msg);
1703 buildPromise = executeBuild(
1704 vercelConfig,
1705 this,
1706 this.files,
1707 match,
1708 requestPath,
1709 false,
1710 filesChanged,
1711 filesRemoved
1712 );
1713 this.inProgressBuilds.set(buildKey, buildPromise);
1714 }
1715 try {
1716 await buildPromise;
1717 } finally {
1718 output.debug(`Built asset ${buildKey}`);
1719 this.inProgressBuilds.delete(buildKey);
1720 }
1721 }

Callers 2

DevServerClass · 0.95

Calls 5

executeBuildFunction · 0.90
debugMethod · 0.80
getMethod · 0.65
setMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected