Skip to content

perf(editor): stop shipping the TypeScript, CSS, HTML and JSON workers - #667

Merged
EVWorth merged 1 commit into
mainfrom
perf/monaco-bundle
Sep 12, 2026
Merged

EVWorth merged 1 commit into
mainfrom
perf/monaco-bundle

Conversation

@EVWorth

@EVWorth EVWorth commented Sep 12, 2026

Copy link
Copy Markdown
Owner

From the full-project review: I built the app and looked at what came out.

import * as monaco from "monaco-editor" is the editor.main barrel, which carries the TypeScript, CSS, HTML and JSON language services. Vite then builds and ships their web workers — in a SQL client that never edits any of those languages.

dist/assets/ts.worker    8,087 kB
dist/assets/css.worker   1,327 kB
dist/assets/html.worker    874 kB
dist/assets/json.worker    525 kB

Importing editor.all (every editor feature, no language services) plus the SQL and MySQL contributions instead:

before after
dist total 17 MB 5.3 MB
monaco chunk 4.25 MB 3.69 MB
workers 10.8 MB 352 kB (the editor worker alone)

Verified in a real browser, not assumed

Loaded the trimmed Monaco in Chromium and asked it:

  • monaco.editor.tokenize("SELECT 1 FROM t", "sql") → keyword.sql, number.sql, identifier.sql — the grammar is there
  • getLanguages() → 2 (sql, mysql), instead of ~90
  • actions.find, editor.foldAll, editor.action.triggerSuggest, editor.action.transformToUppercase, editor.action.commentLine — every action the toolbar and the shortcuts drive

One test-only consequence

Monaco's clipboard contribution asks document.queryCommandSupported at import time, and jsdom does not implement it at all. Stubbed in the shared test setup; a real browser has it.

Docs

ARCHITECTURE's technology table listed monaco-sql-languages, React Flow, Recharts and cmdk — none of which are dependencies — and the system diagram drew an ERD canvas, a dashboard and a command palette, none of which exist. Replaced with what is actually there.

`import * as monaco from "monaco-editor"` is the `editor.main` barrel,
which carries the TypeScript, CSS, HTML and JSON *language services*.
Vite then builds and ships their web workers — ts.worker alone is 8 MB —
in a SQL client that never edits any of those languages.

Importing `editor.all` (every editor feature, no language services) plus
the SQL and MySQL contributions instead:

  dist total   17 MB  ->  5.3 MB
  monaco chunk 4.25 MB -> 3.69 MB
  workers      10.8 MB ->  352 KB (the editor worker alone)

Checked in a real browser rather than assumed: SQL still tokenises
(`keyword.sql`, `number.sql`, `identifier.sql`), two languages are
registered instead of ninety, and find, fold, suggest, uppercase and
comment-line — every action the toolbar and the shortcuts drive — are
all still there.

One test-only consequence: Monaco's clipboard contribution asks
`document.queryCommandSupported` at import time, which jsdom does not
have at all. Stubbed in the shared setup; a real browser has it.

ARCHITECTURE's technology table listed monaco-sql-languages, React Flow,
Recharts and cmdk, none of which are dependencies, and the system
diagram drew an ERD canvas, a dashboard and a command palette, none of
which exist. Replaced with what is there.
@EVWorth
EVWorth merged commit c4589e8 into main Sep 12, 2026
12 checks passed
@EVWorth
EVWorth deleted the perf/monaco-bundle branch September 12, 2026 12:53
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