nodejs-mobile / nodejs-mobile-module-compat

Repo to open issues, discuss and share workarounds about node modules compatibility with nodejs-mobile
0 stars 0 forks source link

deasync #6

Open Delfshkrimm opened 3 years ago

Delfshkrimm commented 3 years ago

Hi,

Thanks for the amazing work on nodejs-mobile! This is truly amazing.

I'm currently trying to have the npm module deasync built for android, using the nodejs-mobile-react-native plugin, but it normally installs using a custom build.js shell script (see package.json).
As stated here, the current implementation for building native modules in nodejs-mobile-react-native requires extra work when not directly using node-gyp.

I wonder what needs to be done for react-native run-android to detect that deasync needs to be compiled using the android toolchains, and how to make it work using their build.js script (I already manage to have this work for more common native modules like leveldown that uses vanilla node-gyp in its install script)/

Thank you in advance

frank-dspeed commented 3 years ago

it does not detect that you ship it pre build normaly

Delfshkrimm commented 3 years ago

Hi! Thanks for your answer @frank-dspeed

I know, the react native gradle script detects that deasync is a native module, but won't compile it against the 4 default toolchains during building process (whereas I have no pb with other modules such as leveldown and ursa)... I think it's because it doesn't use node-gyp in its install script from package.json, but rather use a build.js script (found at the root level: https://github.com/abbr/deasync/blob/master/build.js)

If I refer to the Limitations and future work section of this blog article, this is the expected behavior and needs a bit of tweaking:

Modules that have non-standard build steps (e.g. depending on shell scripts rather than node-gyp, for building) may require further changes to work on mobile.

My question is then: how can I tweak the package.json of deasync or the build.gradle scripts to just make it work? Thank you!

frank-dspeed commented 3 years ago

@Delfshkrimm as wrote on the page that is work that needs to get done but i told you already what needs to get done you prebuild them and ship them.

frank-dspeed commented 3 years ago

and maybe overall more importent i should say that this deasync is scary ..... no one should use that its from a time where we did not got promises and async await and we did not got execSync which we got now so overall it is .... you should forget it anyway.

Delfshkrimm commented 3 years ago

Ah yes thank you! Didn't think of that, you're right. I'll try and figure out the right options from the build script in the nodejs-mobile-react-native package to match how it's done, but on my side.

And yes you're also right, deasync is terrible and this is a temporary only thing I have to do while refactoring the parts of the app I need to fully remove deasync.

Again thanks for your help!