Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

Commit

Permalink
wip: rpc for python builds
Browse files Browse the repository at this point in the history
  • Loading branch information
thdxr committed Oct 7, 2024
1 parent c01e0e6 commit af8a692
Showing 1 changed file with 32 additions and 33 deletions.
65 changes: 32 additions & 33 deletions platform/src/components/aws/function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1182,41 +1182,25 @@ export class Function extends Component implements Link.Linkable {
this.logGroup = logGroup;
this.fnUrl = fnUrl;

all([
dev,
name,
linkData,
args.handler,
args.bundle,
const buildInput = output({
functionID: name,
handler: args.handler,
bundle: args.bundle,
runtime,
args.nodejs,
links: linkData.apply((input) =>
Object.fromEntries(input.map((item) => [item.name, item.properties])),
),
copyFiles,
]).apply(
async ([
dev,
name,
links,
handler,
bundle,
runtime,
nodejs,
copyFiles,
]) => {
if (!dev) return;
await rpc.call("Runtime.AddTarget", {
functionID: name,
handler: handler,
bundle: bundle,
runtime: runtime,
links: Object.fromEntries(
links.map((link) => [link.name, link.properties]),
),
copyFiles: copyFiles,
properties: nodejs,
dev: true,
});
},
);
properties: output({ nodejs: args.nodejs, python: args.python }).apply(
(val) => val.nodejs || val.python,
),
dev,
});

buildInput.apply(async (input) => {
if (!input.dev) return;
await rpc.call("Runtime.AddTarget", input);
});

this.registerOutputs({
_live: unsecret(
Expand Down Expand Up @@ -1464,6 +1448,21 @@ export class Function extends Component implements Link.Linkable {
};
}

if (false) {
const buildResult = buildInput.apply(async (input) => {
const result = await rpc.call<{
handler: string;
out: string;
errors: string[];
}>("Runtime.Build", input);
if (result.errors.length > 0) {
throw new Error(result.errors.join("\n"));
}
return result;
});
return buildResult;
}

if (args.bundle) {
return {
bundle: output(args.bundle),
Expand Down

0 comments on commit af8a692

Please sign in to comment.