feat: on-demand native lib download and optional feature splitting#1039
Draft
msluszniak wants to merge 2 commits intomainfrom
Draft
feat: on-demand native lib download and optional feature splitting#1039msluszniak wants to merge 2 commits intomainfrom
msluszniak wants to merge 2 commits intomainfrom
Conversation
Removes bundled native binaries from the npm package. Libraries are now
downloaded at postinstall time from GitHub Releases, reducing npm install
size and enabling users to opt out of unused dependencies (OpenCV, Phonemizer).
- postinstall script downloads only needed artifacts based on user config
("react-native-executorch": { "extras": [...] } in app's package.json)
- artifacts cached at ~/.cache/react-native-executorch/<version>/ with SHA256 verification
- CMake and podspec conditionally compile/link OpenCV and Phonemizer based
on rne-build-config.json written by the postinstall script
- GlobalThreadPool.h guards cv::setNumThreads(0) with #ifdef RNE_ENABLE_OPENCV
- index.ts startup check validates only core globals; optional feature
globals are allowed absent when those features are disabled
- scripts/package-release-artifacts.sh packages libs into split tarballs
ready for manual upload to GitHub Releases (Phase 1 release flow)
- package.json excludes third-party lib dirs from npm bundle
- .gitignore excludes downloaded lib dirs and rne-build-config.json
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Fixes build failures when RNE_ENABLE_OPENCV=OFF or RNE_ENABLE_PHONEMIZER=OFF: - RnExecutorchInstaller.cpp: guard CV model includes and JSI registrations with #ifdef RNE_ENABLE_OPENCV, phonemizer registration with #ifdef RNE_ENABLE_PHONEMIZER - LLM.cpp: guard VisionEncoder and MultimodalRunner (VLM support) with #ifdef RNE_ENABLE_OPENCV — text-only LLM still works without OpenCV - CMakeLists.txt: add runner/encoders/vision_encoder.cpp, runner/multimodal_prefiller.cpp and runner/multimodal_runner.cpp to OPENCV_CPP_SOURCES so they are excluded when OpenCV is disabled Verified: Android build succeeds with enableOpencv=false, enablePhonemizer=false. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Member
Author
|
TODO: separate xnnpack and coreml backends to separate libs, so they can be opt-out the same way as opencv etc. |
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
package.json, skipping both the download and the native compilation of those dependenciesrne-build-config.jsonfile written by the postinstall scriptHow it works
User configuration (in the app's
package.json):Omitting an extra skips its download and excludes it from the native build.
Artifacts (hosted on GitHub Releases, one tarball per dependency per platform/ABI):
Note: iOS OpenCV comes from CocoaPods (
opencv-rne), no tarball needed.Release flow (Phase 1 — manual upload):
Test plan
A test pre-release
v0.9.0-libs-testhas been published at https://github.com/software-mansion/react-native-executorch/releases/tag/v0.9.0-libs-test with all artifacts uploaded. To verify the full download flow:Expected: all 8 artifacts download, checksum-verify, and extract into the correct
third-party/paths.RNE_ENABLE_OPENCV=OFFRNE_ENABLE_PHONEMIZER=OFFWhat's not in this PR (follow-up)
react-native-executorch/cv,/llm) for ergonomic tree-shaking🤖 Generated with Claude Code