Compiling in a single binary file, currently there is libnut.node, libnut1.node and libnut2.node
augustnmonteiro opened this issue · 4 comments
Short summary
Is there a way we can compile in a single binary file, like: libnut.node would be libnut.node, libnut1.node and libnut2.node combined?
Detailed question
We are having an issue while signing our electron app, because libnut1 and libnut2 don't have types they can't be signed.
Hi @augustnmonteiro 👋
these binaries are platform specific, so having one single uniform binary is not possible.
I'm not 100% sure what "they don't have types" means, do you have a repo I can check out?
Hi @s1hofmann
so, libnut.node
is the windows one?
can I just delete the other 2?
Our application needs to be signed using signtool.exe
and it signs all the binaries that are included in the electron app.
it signes libnut.node
fine, but it doesn't sign the other two, and because of that the build breaks
so, libnut.node is the windows one?
One of them for sure.
I don't know how your build process looks like and how binaries are processed, but one of the *.node
files is targeting Windows.
The other two are built for macOS and Linux.
@s1hofmann I found a fix, thank you!
If someone else has the same problem this is how I solved it.
the file @nut-tree/libnut/index.js
looks like this:
const libnut = (() => {
switch (process.platform) {
case 'win32':
return require(`@nut-tree/libnut-win32`);
case 'linux':
return require(`@nut-tree/libnut-linux`);
case 'darwin':
return require(`@nut-tree/libnut-darwin`);
}
})();
module.exports = libnut;
I created a script to remove the darwin and linux version
const fs = require("fs");
const file = "./node_modules/@nut-tree/libnut/index.js";
let text = fs.readFileSync(file, 'utf-8');
text = text.replace("return require(`@nut-tree/libnut-linux`);", "return;");
text = text.replace("return require(`@nut-tree/libnut-darwin`);", "return;");
fs.writeFileSync(file, text);
I run this right after npm install
In our case we only need the app to work with windows, if you need your app to work with other OS you probably need a different solution