File tree Expand file tree Collapse file tree 2 files changed +23
-4
lines changed
pages/project/[ref]/functions/[functionSlug] Expand file tree Collapse file tree 2 files changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,10 @@ export async function getEdgeFunctionBody(
3333
3434 if ( ! data || ! boundary ) return { files : [ ] }
3535
36+ let metadata : {
37+ deno2_entrypoint_path ?: string | null
38+ } = { }
39+
3640 for await ( let part of parseMultipartStream ( data , {
3741 boundary,
3842 maxFileSize : 20 * 1024 * 1024 ,
@@ -42,10 +46,16 @@ export async function getEdgeFunctionBody(
4246 name : part . filename ,
4347 content : part . text ,
4448 } )
49+ } else {
50+ // treat it as metadata
51+ metadata = JSON . parse ( part . text )
4552 }
4653 }
4754
48- return { files : files as Omit < EdgeFunctionFile , 'id' | 'selected' > [ ] }
55+ return {
56+ metadata,
57+ files : files as Omit < EdgeFunctionFile , 'id' | 'selected' > [ ] ,
58+ }
4959}
5060
5161export type EdgeFunctionBodyData = Awaited < ReturnType < typeof getEdgeFunctionBody > >
Original file line number Diff line number Diff line change @@ -76,7 +76,9 @@ const CodePage = () => {
7676 if ( isDeploying || ! ref || ! functionSlug || ! selectedFunction || files . length === 0 ) return
7777
7878 try {
79- const newEntrypointPath = selectedFunction . entrypoint_path ?. split ( '/' ) . pop ( )
79+ const entrypoint_path =
80+ functionBody ?. metadata ?. deno2_entrypoint_path ?? selectedFunction . entrypoint_path
81+ const newEntrypointPath = entrypoint_path ?. split ( '/' ) . pop ( )
8082 const newImportMapPath = selectedFunction . import_map_path ?. split ( '/' ) . pop ( )
8183
8284 const entrypointExists = fileExists ( newEntrypointPath )
@@ -143,10 +145,17 @@ const CodePage = () => {
143145 }
144146
145147 useEffect ( ( ) => {
148+ if ( ! functionBody ) {
149+ return
150+ }
151+
152+ const entrypoint_path =
153+ functionBody . metadata ?. deno2_entrypoint_path ?? selectedFunction ?. entrypoint_path
154+
146155 // Set files from API response when available
147- if ( selectedFunction ?. entrypoint_path && functionBody ) {
156+ if ( entrypoint_path ) {
148157 const base_path = getBasePath (
149- selectedFunction ?. entrypoint_path ,
158+ entrypoint_path ,
150159 functionBody . files . map ( ( file ) => file . name )
151160 )
152161 const filesWithRelPath = functionBody . files
You can’t perform that action at this time.
0 commit comments