@codemirror/language-data
Language metadata and dynamic loading for every language mode in the CodeMirror 6 editor
Repository Health
Technical Analysis
@codemirror/language-data is the language registry for CodeMirror 6. Rather than bundling every language package into your editor, it exposes a single languages array of LanguageDescription objects, one per supported language, each carrying filename/extension matchers and a dynamic import() loader for that language’s actual mode package. This lets an editor offer language auto-detection and a full language picker while only downloading the parser code a user actually needs.
What You Get
- A
languagesarray ofLanguageDescriptionentries covering ~40 languages, ready to feed into a language-picker UI LanguageDescription.matchFilenameandmatchLanguageNamehelpers for auto-detecting a language from a file path or name- Dynamic
import()-based lazy loading so unused language packages never ship to the browser - A single dependency surface that transitively pulls in the full set of official
@codemirror/lang-*packages for convenience installs
Common Use Cases
- Building a browser-based code editor (like an in-browser IDE or playground) that needs to auto-detect a file’s language from its extension
- Populating a ‘change language’ dropdown in a CodeMirror-based editor without manually importing every language package
- Loading syntax highlighting and language support on demand to keep initial bundle size small in a documentation or notebook tool
- Powering multi-language snippet or gist editors where the language isn’t known until runtime
Under The Hood
Architecture The entire package is a single 1,000-line file, src/language-data.ts, that constructs one flat languages array of LanguageDescription.of({...}) calls, each entry pairing a name, filename/extension regex, optional MIME/alias list, and a load function that returns import('@codemirror/lang-x'). There is no runtime logic beyond this declarative table plus the LanguageDescription class it re-exports from @codemirror/language; matching (matchFilename, matchLanguageName) is delegated entirely to that upstream class. Tech Stack Written in TypeScript, built with CodeMirror’s shared @codemirror/buildhelper tool, and shipped as both ESM (dist/index.js) and CJS (dist/index.cjs) with bundled .d.ts types. Its dependencies list every official @codemirror/lang-* package (JSON, Python, Rust, SQL, YAML, etc.) plus @codemirror/legacy-modes, but none of them are imported eagerly — they only load through the dynamic import() inside each entry’s load function. Code Quality There are no dedicated unit tests in this repository; correctness is exercised indirectly via CodeMirror’s shared cm-runtests harness used across the monorepo-like family of @codemirror/* packages. The single source file is consistent and readable — one repeated object-literal pattern per language — which keeps the risk surface low despite the absence of local tests. API Design The public surface is minimal and ergonomic: import languages and call LanguageDescription.matchFilename(languages, filename) to get a matching description, then .load() to lazily fetch the actual language support. No configuration objects, no build-step wiring, and no boilerplate beyond that one call — the tradeoff is that customizing the language list (adding a custom language) means constructing your own LanguageDescription array rather than extending this one.
Used by 11 apps in this directory
AionUi
AI Agents · Productivity
Free, open-source Cowork desktop app that unifies Claude Code, Codex, Gemini CLI, and 20+ AI agents into a single platform with multi-agent teams, 24/7 cron automation, and zero-config built-in agent.
Apache Answer
Community
Open-source Q&A platform for communities, help centers, and knowledge bases with AI assistant and plugin extensibility
Gitea
Devops · Developer Tools · Project Management
Self-hosted DevOps in a single Go binary — Git hosting, GitHub Actions-compatible CI/CD, and 30+ package registries without any SaaS dependency.
Harness Open Source
Developer Tools · Devops · Code Editors
A unified open source DevOps platform combining Git hosting, CI/CD pipelines, cloud development environments, and artifact registries in a single self-hosted system.
Joplin
Note Taking
The privacy-first, open-source note-taking app with end-to-end encrypted sync, AI assistance, and a powerful plugin ecosystem across every platform.
listmonk
Marketing · Blogging
High-performance, self-hosted newsletter and mailing list manager packaged as a single binary with built-in analytics, transactional messaging, and multi-channel delivery.
marimo
Developer Tools · Data Engineering
A reactive Python notebook that eliminates hidden state, runs reproducibly, and deploys as a web app or script — stored as pure Python, built for the AI era.
massCode
Developer Tools · Productivity · Code Editors
A free, local-first developer workspace unifying snippets, notes, HTTP requests, calculations, drawings, and dev tools in one desktop app.
Open WebUI
AI Assistants · AI Agents
The extensible, privacy-first AI platform that runs Ollama, OpenAI, and any LLM backend behind a polished, feature-packed web interface.