Skip to content

Commit 643e62a

Browse files
committed
fix(builds): fix AWS Lambdas/CGP functions builds
1 parent 83d0292 commit 643e62a

2 files changed

Lines changed: 14 additions & 6 deletions

File tree

packages/whook-aws-lambda/src/index.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,13 +306,17 @@ async function buildHandler(
306306

307307
log('warning', `🏗 - Building ${handlerName}...`);
308308

309-
const lambdaPath = join(PROJECT_DIR, 'builds', APP_ENV, handlerName);
309+
const distPath = join(PROJECT_DIR, 'dist');
310310
const srcPath = join(PROJECT_DIR, 'src');
311-
const srcRelativePath = relative(lambdaPath, srcPath);
311+
const lambdaPath = join(PROJECT_DIR, 'builds', APP_ENV, handlerName);
312+
const distRelativePath = relative(lambdaPath, distPath);
312313

313314
const initializerContent = (
314315
await buildInitializer([`MAIN_HANDLER_${handlerName}`, 'process'])
315-
).replaceAll(pathToFileURL(srcPath).toString(), srcRelativePath);
316+
)
317+
.replaceAll(pathToFileURL(distPath).toString(), distRelativePath)
318+
.replaceAll(pathToFileURL(srcPath).toString(), distRelativePath)
319+
.replaceAll(".ts';", ".js';");
316320
const indexContent = await buildHandlerIndex(
317321
{ SCHEMA_VALIDATORS_OPTIONS },
318322
`MAIN_HANDLER_${handlerName}`,

packages/whook-gcp-functions/src/index.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,13 +245,17 @@ async function buildHandler(
245245

246246
log('warning', `🏗 - Building "${handlerName}"...`);
247247

248-
const handlerPath = join(PROJECT_DIR, 'builds', APP_ENV, handlerName);
248+
const distPath = join(PROJECT_DIR, 'dist');
249249
const srcPath = join(PROJECT_DIR, 'src');
250-
const srcRelativePath = relative(handlerPath, srcPath);
250+
const handlerPath = join(PROJECT_DIR, 'builds', APP_ENV, handlerName);
251+
const distRelativePath = relative(handlerPath, distPath);
251252

252253
const initializerContent = (
253254
await buildInitializer([`MAIN_HANDLER_${handlerName}`])
254-
).replaceAll(pathToFileURL(srcPath).toString(), srcRelativePath);
255+
)
256+
.replaceAll(pathToFileURL(distPath).toString(), distRelativePath)
257+
.replaceAll(pathToFileURL(srcPath).toString(), distRelativePath)
258+
.replaceAll(".ts';", ".js';");
255259
const indexContent = await buildHandlerIndex(
256260
{ SCHEMA_VALIDATORS_OPTIONS },
257261
`MAIN_HANDLER_${handlerName}`,

0 commit comments

Comments
 (0)