Skip to content Skip to sidebar Skip to footer

Is It Possible To Shim Node's Fs.readfilesync() In React Native?

I want to port a number of packages written for NodeJS to React Native. For this purpose I created a RN project using the popular Ignite boilerplate, then used the ReactNativify me

Solution 1:

No. There is no reasonable alternative for Node's fs.readFileSync.

Though technically it is possible to write a readFileSync shim that blocks on an asynchronous file operation, it is inadvisable to force synchronous behavior in an asynchronous system (but you may be able to get away with it, when only having few synchronous methods in one-time initialization code).

So option 3 or 4 are the only viable alternatives.

In my case there were too many Node dependencies, so I ditched browserifying / shimming and opted for 4. But ...

That does not mean all is necessarily lost. I am now investigating Compiling NodeJS as native library in Android

(And Realm.io to bridge native NodeJS + React Native in Android fat client app (CQRS-style)).

Post a Comment for "Is It Possible To Shim Node's Fs.readfilesync() In React Native?"