[WIP] Nitro Modules Migration #89
Draft
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.
🚀 Nitro Modules Migration + Streaming API (Beta)
Overview
This is a major release that completely reimagines
react-native-fs2
by migrating from the legacy React Native architecture to Nitro Modules, bringing significant performance improvements and introducing a powerful new File Streaming API.🎯 Key Changes
✨ Migration to Nitro Modules
The entire native bridge has been rewritten using Nitro Modules, providing:
🌊 Streaming API (Beta)
Introducing a new File Streaming API for efficient handling of large files:
Read Streams
Write Streams
Key Features
See FILE_STREAM.md for complete documentation.
📋 Changes & Compatibility
✅ Mostly Backward Compatible!
The core API remains backward compatible - most existing code will work without changes!
Required Dependencies
You'll need to add Nitro Modules as a peer dependency:
API Improvements (Non-Breaking)
Backward Compatible File Operations
The core file API remains backward compatible! You can still use the same API:
Under the hood: The native bridge now uses
ArrayBuffer
for better performance and smaller memory footprint, but encoding/decoding is handled transparently in JavaScript. No code changes required!Download API - Fully Backward Compatible
The download API remains 100% backward compatible:
Internal improvement: Under the hood, the download system now uses Nitro's event listeners for better performance, but the public API is unchanged.
Minor Type Changes (May Require Updates)
These are the only potential breaking changes:
Timestamps as numbers:
ReadDirItem
andstat()
now return timestamps as numbers (milliseconds since epoch) instead of Date objectsStricter types: Hash algorithms and file protection types are now union types for better type safety
🎁 New Features
Stream API
Enhanced MediaStore Support (Android)
MediaStore functionality remains available with improved type safety and performance.
Improved Error Handling
Better error messages with platform-specific error codes and context.
🚀 Performance Improvements
📚 Documentation
New documentation added:
🔧 Migration Guide
1. Install Dependencies
2. Update Imports
3. Verify File Operations
Most file operations are backward compatible - no changes needed! The same API works:
4. (Optional) Explore New Features
Check out the new capabilities:
5. Test Key Areas
Since most APIs are backward compatible, focus testing on:
mtime
/ctime
fromstat()
orreadDir()
(now numbers instead of Date)🐛 Known Issues
🙏 Acknowledgments
This major release builds upon the foundation of
react-native-fs
and leverages the incredible work of:📦 Package Info
Testing Checklist
Note: This is a major version bump due to the architectural change and new peer dependency requirement. The API is mostly backward compatible with only minor type changes for timestamps. Most apps can upgrade with minimal changes!