feat: allow opting out of tree-sitter & RaTeX downloads via package.json - #661
Merged
Conversation
eszlamczyk
requested review from
hryhoriiK97
and
a lite review from Copilot
and removed request for
Copilot
August 13, 2026 12:36
There was a problem hiding this comment.
Pull request overview
Adds a consumer-controlled opt-out mechanism to skip downloading large native assets (tree-sitter grammars/runtime and the iOS RaTeX XCFramework) during install, while keeping native builds working by auto-disabling features when assets aren’t present.
Changes:
- Read
"enriched-markdown"config from the consumer app’spackage.json(viaINIT_CWD) inpostinstall.mjsto conditionally skip tree-sitter and/or RaTeX downloads. - Make iOS/Android native build logic default feature enablement based on vendored asset presence, so “skipped download” doesn’t break builds.
- Update docs/README to document the opt-out configuration and revised recovery/behavior.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents the new package.json opt-out and links to native-asset instructions. |
| packages/react-native-enriched-markdown/ReactNativeEnrichedMarkdown.podspec | Makes iOS math enablement track RaTeX presence (unless forced by env) and warns when auto-disabled. |
| packages/react-native-enriched-markdown/postinstall.mjs | Reads consumer package.json to skip downloading optional native assets. |
| packages/react-native-enriched-markdown/android/build.gradle | Defaults Android code highlighting enablement based on vendored asset presence unless a Gradle property overrides. |
| packages/core/cpp/highlight/code_highlight_podspec.rb | Falls back to the disabled/no-op highlight stub when the vendored runtime isn’t present. |
| docs/NATIVE_ASSETS.md | Adds “Skipping the download (opt out)” section and updates recovery guidance. |
| docs/LATEX_MATH.md | Documents skipping the RaTeX download via package.json and the new iOS auto-disable behavior. |
| docs/CODE_HIGHLIGHT.md | Documents skipping grammar downloads via package.json and points to native assets docs. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
hryhoriiK97
approved these changes
Aug 13, 2026
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.
What/Why?
Consumers can now skip the heavy install-time native asset downloads (tree-sitter grammars ~169 MB, RaTeX XCFramework ~47 MB, added in #660) when they don't use code highlighting and/or LaTeX math. Following Reanimated's convention, the opt-out is a declarative block in the consumer's own
package.json:{ "enriched-markdown": { "enableCodeHighlight": false, "enableMath": false } }Both fields default to true (opt-out, not opt-in), and are read from the consumer project only (via INIT_CWD), so
there's no effect on this repo's own monorepo development.
Two parts:
the grammar and/or RaTeX download accordingly; early-exits when both are disabled. Any resolution failure (no INIT_CWD, malformed JSON, missing key) falls back to downloading everything — a skipped download is cheaper to recover from than a silently missing feature.
Existing ENRICHED_MARKDOWN_ENABLE_* env / enrichedMarkdown.enable* gradle overrides are unchanged. Android math is unaffected (it uses a Maven dependency, not the vendored XCFramework).
Testing
Built the real publish tarball (npm pack) and installed it into throwaway /tmp consumer projects with different
Verified the native-side auto-disable against the installed layouts:
sources, ENRICHED_MARKDOWN_CODE_HIGHLIGHT=1.
Also ran postinstall.mjs directly against a published-layout sandbox across all config permutations (no key / both off / each off / malformed JSON / no INIT_CWD) — all gate as designed. ruby -c clean on both podspecs.
PR Checklist