Skip to content

Modular language architecture to reduce library size#3

Open
gtokman wants to merge 1 commit intomainfrom
claude/reduce-library-size-8R6c2
Open

Modular language architecture to reduce library size#3
gtokman wants to merge 1 commit intomainfrom
claude/reduce-library-size-8R6c2

Conversation

@gtokman
Copy link
Copy Markdown
Collaborator

@gtokman gtokman commented Mar 25, 2026

Summary

  • Moves all 19 tree-sitter language parsers from the core MarkdownView target into a new MarkdownLanguages module, eliminating ~40 MB of compiled C parsers from the core library
  • Adds a public CodeHighlighter.registerLanguage(aliases:factory:) API for dynamic language registration
  • Introduces two library products: MarkdownView (slim core) and MarkdownViewAll (backward-compatible, all languages bundled)
  • Updates README with installation instructions for both products

How it works

Each tree-sitter language parser is a compiled C library adding ~2-3 MB to the binary. Previously all 19 were statically linked into the MarkdownView target regardless of usage. Now:

Product Includes Estimated size savings
MarkdownView Core renderer + SwiftTreeSitter framework only ~40 MB smaller
MarkdownViewAll Everything (same as before) No change

Consumers using MarkdownViewAll call MarkdownLanguages.registerAll() at app launch. Consumers using the slim MarkdownView register only the languages they need via the public API.

Test plan

  • Verify MarkdownViewAll product builds and all tests pass with MarkdownLanguages.registerAll()
  • Verify MarkdownView product builds without language dependencies
  • Verify individual language registration works via CodeHighlighter.registerLanguage
  • Verify syntax highlighting still works for all 19 languages

https://claude.ai/code/session_01UUwW6MSS7YZh2L3Z7FaHY5

Move all 19 tree-sitter language parsers from the core MarkdownView target
into a separate MarkdownLanguages module. This allows consumers to choose:

- MarkdownViewAll: full library with all languages (backward-compatible)
- MarkdownView: core only (~40 MB smaller), register languages individually

CodeHighlighter now exposes a public registerLanguage(aliases:factory:) API
for dynamic language registration instead of hardcoding all imports.

https://claude.ai/code/session_01UUwW6MSS7YZh2L3Z7FaHY5
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 25, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
markdown-view Ready Ready Preview, Comment, Open in v0 Mar 25, 2026 0:17am

Request Review

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.

2 participants