({
files,
entrypoint,
shim,
useWebApi,
workPath,
repoRootPath,
config = {},
meta = {},
service,
considerBuildCommand = false,
entrypointCallback,
checks = () => {},
}: Parameters<BuildV3>[0] & {
shim?: (handler: string) => string;
useWebApi?: boolean;
considerBuildCommand?: boolean;
/**
* This is called once any user build scripts have run so that the entrypoint can be detected
* from files that may have been created by the build script.
*/
entrypointCallback?: () => Promise<string>;
checks?: (project: { config: Config; isBun: boolean }) => void;
})
| 426 | } |
| 427 | |
| 428 | export const build = async ({ |
| 429 | files, |
| 430 | entrypoint, |
| 431 | shim, |
| 432 | useWebApi, |
| 433 | workPath, |
| 434 | repoRootPath, |
| 435 | config = {}, |
| 436 | meta = {}, |
| 437 | service, |
| 438 | considerBuildCommand = false, |
| 439 | entrypointCallback, |
| 440 | checks = () => {}, |
| 441 | }: Parameters<BuildV3>[0] & { |
| 442 | shim?: (handler: string) => string; |
| 443 | useWebApi?: boolean; |
| 444 | considerBuildCommand?: boolean; |
| 445 | /** |
| 446 | * This is called once any user build scripts have run so that the entrypoint can be detected |
| 447 | * from files that may have been created by the build script. |
| 448 | */ |
| 449 | entrypointCallback?: () => Promise<string>; |
| 450 | checks?: (project: { config: Config; isBun: boolean }) => void; |
| 451 | }): Promise<BuildResultV3> => { |
| 452 | const baseDir = repoRootPath || workPath; |
| 453 | const awsLambdaHandler = getAWSLambdaHandler(entrypoint, config); |
| 454 | |
| 455 | const { |
| 456 | entrypointPath: _entrypointPath, |
| 457 | entrypointFsDirname, |
| 458 | nodeVersion, |
| 459 | spawnEnv, |
| 460 | cliType, |
| 461 | lockfilePath, |
| 462 | lockfileVersion, |
| 463 | } = await downloadInstallAndBundle({ |
| 464 | files, |
| 465 | entrypoint, |
| 466 | workPath, |
| 467 | config, |
| 468 | meta, |
| 469 | considerBuildCommand, |
| 470 | }); |
| 471 | |
| 472 | let entrypointPath = _entrypointPath; |
| 473 | |
| 474 | const projectBuildCommand = config.projectSettings?.buildCommand; |
| 475 | |
| 476 | // For traditional api-folder builds, the `build` script or project build command isn't used. |
| 477 | // but we're reusing the node builder for hono and express, where they should be treated as the |
| 478 | // primary builder |
| 479 | if (projectBuildCommand && considerBuildCommand) { |
| 480 | await execCommand(projectBuildCommand, { |
| 481 | // Yarn v2 PnP mode may be activated, so force |
| 482 | // "node-modules" linker style |
| 483 | env: { |
| 484 | YARN_NODE_LINKER: 'node-modules', |
| 485 | ...spawnEnv, |
no test coverage detected