( config: ResolvedConfig, options: DeployCommandOptions, configPath?: string )
| 1094 | } |
| 1095 | |
| 1096 | async function compileProject( |
| 1097 | config: ResolvedConfig, |
| 1098 | options: DeployCommandOptions, |
| 1099 | configPath?: string |
| 1100 | ) { |
| 1101 | return await tracer.startActiveSpan("compileProject", async (span) => { |
| 1102 | try { |
| 1103 | if (!options.skipTypecheck) { |
| 1104 | const typecheck = await typecheckProject(config, options); |
| 1105 | |
| 1106 | if (!typecheck) { |
| 1107 | throw new Error("Typecheck failed, aborting deployment"); |
| 1108 | } |
| 1109 | } |
| 1110 | |
| 1111 | const compileSpinner = spinner(); |
| 1112 | compileSpinner.start(`Building project in ${config.projectDir}`); |
| 1113 | |
| 1114 | const taskFiles = await gatherTaskFiles(config); |
| 1115 | const workerFacade = readFileSync( |
| 1116 | join(cliRootPath(), "workers", "prod", "worker-facade.js"), |
| 1117 | "utf-8" |
| 1118 | ); |
| 1119 | |
| 1120 | const workerSetupPath = join(cliRootPath(), "workers", "prod", "worker-setup.js"); |
| 1121 | |
| 1122 | let workerContents = workerFacade |
| 1123 | .replace("__TASKS__", createTaskFileImports(taskFiles)) |
| 1124 | .replace( |
| 1125 | "__WORKER_SETUP__", |
| 1126 | `import { tracingSDK, otelTracer, otelLogger } from "${escapeImportPath( |
| 1127 | workerSetupPath |
| 1128 | )}";` |
| 1129 | ); |
| 1130 | |
| 1131 | if (configPath) { |
| 1132 | logger.debug("Importing project config from", { configPath }); |
| 1133 | |
| 1134 | workerContents = workerContents.replace( |
| 1135 | "__IMPORTED_PROJECT_CONFIG__", |
| 1136 | `import * as importedConfigExports from "${escapeImportPath( |
| 1137 | configPath |
| 1138 | )}"; const importedConfig = importedConfigExports.config; const handleError = importedConfigExports.handleError;` |
| 1139 | ); |
| 1140 | } else { |
| 1141 | workerContents = workerContents.replace( |
| 1142 | "__IMPORTED_PROJECT_CONFIG__", |
| 1143 | `const importedConfig = undefined; const handleError = undefined;` |
| 1144 | ); |
| 1145 | } |
| 1146 | |
| 1147 | const result = await build({ |
| 1148 | stdin: { |
| 1149 | contents: workerContents, |
| 1150 | resolveDir: process.cwd(), |
| 1151 | sourcefile: "__entryPoint.ts", |
| 1152 | }, |
| 1153 | bundle: true, |
no test coverage detected
searching dependent graphs…