Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/composables/useMonacoEditor.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import type { Ref } from 'vue'
import type { SqlStatement, StatementToExecute } from './useSqlStatements'
import * as monaco from 'monaco-editor'
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api'
import EditorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker'
import { onBeforeUnmount } from 'vue'

import {
getSqlGutterDecorations,
getStatementAtLine,
Expand All @@ -13,6 +14,12 @@ import {
} from './useSqlStatements'
import { useTheme } from './useTheme'

// Import only SQL-related grammars instead of all Monaco languages
// (Typescript/CSS/HTML/JSON workers alone add ~8MB to the bundle).
import 'monaco-editor/esm/vs/basic-languages/sql/sql.contribution'
import 'monaco-editor/esm/vs/basic-languages/mysql/mysql.contribution'
import 'monaco-editor/esm/vs/basic-languages/pgsql/pgsql.contribution'

export type { ExecuteSource, StatementToExecute } from './useSqlStatements'

// Configure Monaco Editor workers for Vite
Expand Down
6 changes: 6 additions & 0 deletions types/vite-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@ declare module '*.vue' {
const component: InstanceType<DefineComponent>
export default component
}

// Monaco Editor API without built-in language contributions
// Types are identical to the main monaco-editor bundle.
declare module 'monaco-editor/esm/vs/editor/editor.api' {
export * from 'monaco-editor'
}
Loading