Improving DX of co-shipping Node.js prebuilds #146
Replies: 2 comments 2 replies
-
I’ve run into problems with this kind of thing in other contexts, using an ARM Windows VM on a Mac. We probably do want to reach a solution that distinguishes operating system. While they surely exist, I think it’s relatively rare that all of your project’s Node-API modules happen to be OS-agnostic libraries that only need to be split on an architecture. |
Beta Was this translation helpful? Give feedback.
-
I think this is the right solution, and only a naming problem. I’m not even convinced we have to rename it. It was made “for” RN, but respects the wider ecosystem too. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Library authors might want to publish packages containing prebuilds for Node.js alongside the React Native specific prebuilds, if they have a use-case for targeting Node.js or wants to make it easier for app developers to test without having to mock the native addon of the library.
Library authors can use
cmake-js
,node-gyp
(if they use CMake or GYP respectively) to build for Node.js.Annoyance 1: Prebuild / output location
By default, both
cmake-js
andnode-gyp
output the dynamic library produced when building to${projectRoot}/build/${configuration}/${targetName}.node
.☝ has the disadvantage that dynamic libraries compiled on different operating systems / architectures share the same path of disk.
Developers use tools like
prebuild
orprebuildify
(supports only GYP), to build and structure multiple os+arch specific binaries.The
cmake-rn
store its output platform-specific & arch-specific subdirectories of${projectRoot}
(see out PREBUILDS.md for details on the structure of these directories).Note
${projectRoot}
in the paths above is not the package root, but instead the directory containing thebinding.gyp
orCMakeLists.txt
configurations of the particular build system.Annoyance 2: Executing two commands
It's annoying to have to invoke multiple tools (which might have slightly different runtime options / args).
Ideally a library author should be able to just select the platforms / triplets they want to build for:
To be more compatible with the existing tools for Node.js, we could:
${projectRoot}/build/${configuration}
directory, the same waycmake-js
andnode-gyp
does: I've opened Add--out-to-build
option #148 to add an opt-in option for this.cmake-rn
(feels wrong, as the-rn
suffix).cmake-js
andcmake-rn
(feels a bit too abstracted).Beta Was this translation helpful? Give feedback.
All reactions