Skip to content

chore(example): rebuild the monaco-editor example with Vite - #264

Merged
joe-re merged 2 commits into
releasefrom
chore/rebuild-monaco-example
Sep 27, 2026
Merged

joe-re merged 2 commits into
releasefrom
chore/rebuild-monaco-example

Conversation

@joe-re

@joe-re joe-re commented Sep 25, 2026 •

Copy link
Copy Markdown
Owner

Summary

Phase 7 of the maintenance plan: rebuild example/monaco_editor.

Why not monaco-languageclient

The current monaco-languageclient (11.x) depends on ~35 @codingame/monaco-vscode-* packages that get major releases every few weeks, which is a lot of upkeep for a one-page demo. monaco-editor's own native LSP client (lsp.MonacoLspClient, 0.55+) only exposes new MonacoLspClient(transport), so it cannot send rootPath, listen to the server's custom notifications (sqlLanguageServer.finishSetup / error), or send workspace/executeCommand. So this uses a small hand-written bridge instead.

What's here

  • Vite + monaco-editor (no Svelte / webpack / loaders)
  • src/lspClient.ts (~270 lines): text sync, publishDiagnostics -> markers, completion, code actions (with the original LSP diagnostics), workspace/applyEdit, workspace/configuration, executeCommand, custom notifications, auto-reconnect when the server restarts
  • server/server.ts: runs sql-language-server in-process per WebSocket connection on /lsp (via vscode-ws-jsonrpc); also serves dist/ after pnpm build
  • db/init.sql: one sample schema for all adapters. Postgres / MySQL load it via docker-entrypoint-initdb.d; pnpm setup:sqlite creates sample.sqlite3 with node:sqlite. The example now works without Docker (sqlite).
  • sequelize / sequelize-cli migrations are removed

docker-compose

  • Removed NODE_OPTIONS=--openssl-legacy-provider (webpack 4-era workaround) and the linux/x86_64 platform pins
  • New volume names postgres17 / mysql84, so old postgres 10 data does not break startup
  • pnpm's store now lives in a volume (pnpm_config_store_dir; pnpm 11 ignores npm_config_*). Before, pnpm install inside the container created .pnpm-store/ in the mounted repository.

CI

  • Root pnpm typecheck includes the example, and CI runs vite build for it

Test plan

  • Headless Chrome against pnpm dev (Vite) and pnpm build && pnpm start: lint squiggles appear, SELECT * FROM completion lists users / posts from sqlite, "Fix all auto-fixable problems" rewrites the query, no page errors
  • docker compose up from fresh node_modules volumes: install succeeds, no .pnpm-store/ is created in the repository, the connection selector lists sqlite / postgres / mysql, and completion lists users / posts for sqlite and postgres_db.users / mysql_db.users after switching
  • build / lint / typecheck / all tests

Known server issue found while testing (not changed here)

SettingStore.setSetting merges the new connection into the previous state (Object.assign({}, this.state, newSetting)), so fields the new connection does not set leak from the old one. After switching mysql -> sqlite, completion shows mysql_db.users for sqlite tables. The same happens in VS Code. Worth a separate fix.

- Replace webpack + Svelte + monaco-languageclient 0.13 with Vite and
  monaco-editor, plus a small LSP bridge (src/lspClient.ts) covering what the
  server implements: text sync, diagnostics, completion, code actions,
  workspace/applyEdit, executeCommand and the custom notifications
- server/server.ts runs sql-language-server per WebSocket connection on /lsp
  and serves dist/ when built; Vite proxies /lsp during development
- Replace the sequelize migrations with db/init.sql, loaded by postgres and
  mysql through docker-entrypoint-initdb.d and into sqlite by setup:sqlite
- The example now works without Docker using sqlite
- docker-compose: drop --openssl-legacy-provider and x86_64 platform pins,
  use new volume names for postgres 17 / mysql 8.4 data, and keep the pnpm
  store in a volume instead of the mounted repository
- Type-check and build the example in CI
pnpm 11 reads pnpm_config_* environment variables, so npm_config_store_dir
was ignored and the store was still created in the mounted repository.
@joe-re
joe-re merged commit f522b60 into release Sep 27, 2026
5 checks passed
@joe-re
joe-re deleted the chore/rebuild-monaco-example branch September 27, 2026 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant