Closed chaodoze closed 7 years ago
There's absolutely no way to make synchronous disk I/O work in React Native. You could probably polyfill the async methods in fs
by writing your own Native Module, and then aliasing that to fs
using babel-plugin-rewrite-require, as demonstrated here. If you get that working, please do send a PR, I'd be happy to include it in ReactNativify as an example.
That said, if you're relying on a third party package that reads a configuration file from disk synchronously, you should really ask yourself if you want to be reusing that code in React Native. It might be easier to rewrite it yourself, patch it to not do that, or to give it a fake fs
module that will actually read the data from a place in memory, where you've been able to populate it.
In particular, fs.readFileSync() - many node packages use that to read a local, say config, file.