From 9b99b87f2b45ac478b2f091e9520668f4bda97ee Mon Sep 17 00:00:00 2001 From: Lakshan Perera Date: Mon, 7 Apr 2025 09:25:57 +1000 Subject: [PATCH] fix: support editing functions with static files --- apps/studio/lib/eszip-parser.ts | 1 - .../project/[ref]/functions/[functionSlug]/code.tsx | 9 ++++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/studio/lib/eszip-parser.ts b/apps/studio/lib/eszip-parser.ts index bf84bc38c6a..44a4d38d8b4 100644 --- a/apps/studio/lib/eszip-parser.ts +++ b/apps/studio/lib/eszip-parser.ts @@ -92,7 +92,6 @@ async function extractEszip(parser: any, specifiers: string[]) { const shouldSkip = specifier.startsWith('---') || specifier.startsWith('npm:') || - specifier.startsWith('static:') || specifier.startsWith('vfs:') || specifier.startsWith('https:') || specifier.startsWith('jsr:') diff --git a/apps/studio/pages/project/[ref]/functions/[functionSlug]/code.tsx b/apps/studio/pages/project/[ref]/functions/[functionSlug]/code.tsx index 4c56e5b49a6..0338f7cdd33 100644 --- a/apps/studio/pages/project/[ref]/functions/[functionSlug]/code.tsx +++ b/apps/studio/pages/project/[ref]/functions/[functionSlug]/code.tsx @@ -1,4 +1,4 @@ -import { common, dirname, relative } from '@std/path/posix' +import { common, dirname, relative, extname } from '@std/path/posix' import { AlertCircle, CornerDownLeft, Loader2 } from 'lucide-react' import { useRouter } from 'next/router' import { useEffect, useState } from 'react' @@ -97,6 +97,12 @@ const CodePage = () => { return files.find(({ name }) => regex.test(name))?.name } + const validSourceExtensions = ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.json'] + const static_patterns = [...new Set(files.map(({ name }) => { + const ext = extname(name) + return validSourceExtensions.includes(ext) ? null : `*${ext}` + }).filter(item => item !== null && item !== undefined))] + deployFunction({ projectRef: ref, slug: selectedFunction.slug, @@ -109,6 +115,7 @@ const CodePage = () => { import_map_path: files.some(({ name }) => name === newImportMapPath) ? newImportMapPath : fallbackImportMapPath(), + static_patterns, }, files: files.map(({ name, content }) => ({ name, content })), })