The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
[FE-2227] chore: Refactor the Deno libraries to be bundled loaded as dynamic ES modules (#41595)
Ivan Vasilovf346518fe312
diff --git a/apps/studio/components/ui/AIEditor/index.tsx b/apps/studio/components/ui/AIEditor/index.tsxindex 88a9403f4f3..38e858ab1ab 100644--- a/apps/studio/components/ui/AIEditor/index.tsx+++ b/apps/studio/components/ui/AIEditor/index.tsx@@ -38,7 +38,7 @@ interface AIEditorProps {// Can we try to de-dupe accordingly? Perhaps the SQL Editor could use this AIEditor// We have a tendency to create multiple versions of the monaco editor like RLSCodeEditor// so hoping to prevent that from snowballing-const AIEditor = ({+export const AIEditor = ({language = 'javascript',value,defaultValue = '',@@ -200,18 +200,24 @@ const AIEditor = ({diagnosticCodesToIgnore: [2792],})- fetch(`${process.env.NEXT_PUBLIC_BASE_PATH ?? ''}/deno/lib.deno.d.ts`)- .then((response) => response.text())- .then((code) => {- monaco.languages.typescript.typescriptDefaults.addExtraLib(code)- })-- // Add edge runtime types to the TS language service- fetch(`${process.env.NEXT_PUBLIC_BASE_PATH ?? ''}/deno/edge-runtime.d.ts`)- .then((response) => response.text())- .then((code) => {- monaco.languages.typescript.typescriptDefaults.addExtraLib(code)- })+ if (language === 'javascript' || language === 'typescript') {+ // The Deno libs are loaded as a raw text via raw-loader in next.config.js. They're passed as raw text to the+ // Monaco editor.+ import('public/deno/edge-runtime.d.ts' as string)+ .then((module) => {+ monaco.languages.typescript.typescriptDefaults.addExtraLib(module.default)+ })+ .catch((error) => {+ console.error('Failed to load Deno edge-runtime typings:', error)+ })+ import('public/deno/lib.deno.d.ts' as string)+ .then((module) => {+ monaco.languages.typescript.typescriptDefaults.addExtraLib(module.default)+ })+ .catch((error) => {+ console.error('Failed to load Deno lib typings:', error)+ })+ }if (!!executeQueryRef.current) {editor.addAction({@@ -458,5 +464,3 @@ const AIEditor = ({</div>)}--export default AIEditordiff --git a/apps/studio/components/ui/EditorPanel/EditorPanel.tsx b/apps/studio/components/ui/EditorPanel/EditorPanel.tsxindex 10e5ffa1a5c..7266d6f1240 100644--- a/apps/studio/components/ui/EditorPanel/EditorPanel.tsx+++ b/apps/studio/components/ui/EditorPanel/EditorPanel.tsx@@ -3,6 +3,8 @@ import { useRouter } from 'next/router'import { useState } from 'react'import { LOCAL_STORAGE_KEYS, useParams } from 'common'+import { isExplainQuery } from 'components/interfaces/ExplainVisualizer/ExplainVisualizer.utils'+import { generateSnippetTitle } from 'components/interfaces/SQLEditor/SQLEditor.constants'import {createSqlSnippetSkeletonV2,suffixWithLimit,@@ -40,11 +42,9 @@ import {} from 'ui'import { Admonition } from 'ui-patterns'import { containsUnknownFunction, isReadOnlySelect } from '../AIAssistantPanel/AIAssistant.utils'-import AIEditor from '../AIEditor'+import { AIEditor } from '../AIEditor'import { ButtonTooltip } from '../ButtonTooltip'import { SqlWarningAdmonition } from '../SqlWarningAdmonition'-import { isExplainQuery } from 'components/interfaces/ExplainVisualizer/ExplainVisualizer.utils'-import { generateSnippetTitle } from 'components/interfaces/SQLEditor/SQLEditor.constants'export const EditorPanel = () => {const {diff --git a/apps/studio/components/ui/FileExplorerAndEditor/index.tsx b/apps/studio/components/ui/FileExplorerAndEditor/index.tsxindex 51628b36adb..07c7450472b 100644--- a/apps/studio/components/ui/FileExplorerAndEditor/index.tsx+++ b/apps/studio/components/ui/FileExplorerAndEditor/index.tsx@@ -1,9 +1,9 @@import { AnimatePresence, motion } from 'framer-motion'import { Edit, File, Plus, Trash } from 'lucide-react'import { useEffect, useState } from 'react'--import AIEditor from 'components/ui/AIEditor'import { toast } from 'sonner'++import { AIEditor } from 'components/ui/AIEditor'import {Button,ContextMenu_Shadcn_,diff --git a/apps/studio/next.config.js b/apps/studio/next.config.jsindex 31fdddf43bc..d49a79c513f 100644--- a/apps/studio/next.config.js+++ b/apps/studio/next.config.js@@ -566,6 +566,15 @@ const nextConfig = {loaders: ['raw-loader'],as: '*.js',},+ // special case for Deno libs to be loaded as a raw text. They're passed as raw text to the Monaco editor.+ 'edge-runtime.d.ts': {+ loaders: ['raw-loader'],+ as: '*.js',+ },+ 'lib.deno.d.ts': {+ loaders: ['raw-loader'],+ as: '*.js',+ },},},onDemandEntries: {