From bac9f321863deb6789f27880b274af7dc1abcf03 Mon Sep 17 00:00:00 2001 From: James Garbutt <43081j@users.noreply.github.com> Date: Wed, 30 Jul 2025 09:54:36 +0100 Subject: [PATCH] fix: support new functions getter in edge functions The `serve` function now accepts a functions getter rather than a plain object. For example: ```ts serve(async () => { return { someFunction: await doSomethingAsync() } }, metadata); ``` --- packages/edge-bundler/node/formats/javascript.ts | 2 +- packages/edge-bundler/node/stage_2.test.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/edge-bundler/node/formats/javascript.ts b/packages/edge-bundler/node/formats/javascript.ts index 0e7ae20962..5e669799ce 100644 --- a/packages/edge-bundler/node/formats/javascript.ts +++ b/packages/edge-bundler/node/formats/javascript.ts @@ -78,7 +78,7 @@ const getLocalEntryPoint = ( } ` }) - const bootCall = `boot(functions, metadata);` + const bootCall = `boot(() => functions, metadata);` return [bootImport, declaration, ...imports, bootCall].join('\n\n') } diff --git a/packages/edge-bundler/node/stage_2.test.ts b/packages/edge-bundler/node/stage_2.test.ts index 4658b260f1..414657a5da 100644 --- a/packages/edge-bundler/node/stage_2.test.ts +++ b/packages/edge-bundler/node/stage_2.test.ts @@ -14,8 +14,9 @@ test('`getLocalEntryPoint` returns a valid stage 2 file for local development', // This is a fake bootstrap that we'll create just for the purpose of logging // the functions and the metadata that are sent to the `boot` function. const printer = ` - export const boot = async (functions, metadata) => { + export const boot = async (getFunctions, metadata) => { const responses = {} + const functions = await getFunctions() for (const name in functions) { responses[name] = await functions[name]()