Modular language architecture to reduce library size#3
Open
Conversation
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
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MarkdownViewtarget into a newMarkdownLanguagesmodule, eliminating ~40 MB of compiled C parsers from the core libraryCodeHighlighter.registerLanguage(aliases:factory:)API for dynamic language registrationMarkdownView(slim core) andMarkdownViewAll(backward-compatible, all languages bundled)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
MarkdownViewtarget regardless of usage. Now:MarkdownViewMarkdownViewAllConsumers using
MarkdownViewAllcallMarkdownLanguages.registerAll()at app launch. Consumers using the slimMarkdownViewregister only the languages they need via the public API.Test plan
MarkdownViewAllproduct builds and all tests pass withMarkdownLanguages.registerAll()MarkdownViewproduct builds without language dependenciesCodeHighlighter.registerLanguagehttps://claude.ai/code/session_01UUwW6MSS7YZh2L3Z7FaHY5