Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pre-built binaries #29

Open
JoCat opened this issue Nov 1, 2024 · 6 comments
Open

Pre-built binaries #29

JoCat opened this issue Nov 1, 2024 · 6 comments
Assignees
Milestone

Comments

@JoCat
Copy link

JoCat commented Nov 1, 2024

I propose to add a binary build for the module to save users from unnecessary build steps and make it possible to conveniently work with the package as a dependency in other projects.


UPD Oh wait, I seem to have misunderstood how I'm supposed to interact with the built .node files when including them in my project


UPD2 I think I'm confused, so I'll wait for your opinion on this.

@Winterreisender
Copy link
Owner

Winterreisender commented Nov 2, 2024

In the earlier version(maybe 0.1), there were prebuilt binaries instead of building during installation.
I changed the plan to build during installation at that time because:

  • It's the common practice in node.js
  • It's hard to make .node file for every platform and every node.js version
  • If we use prebuilt version, there's 3 choices: node-ffi-napi is not actively maintained, koffi has a serious bug that cannot be solved and node:ffi is experimental at that time.
  • the webview/webview provide a swig file so that we can easily make a node napi extension.

So, do we need try to provide prebuilt binaries now? If I have time, I'd like to try, especially node:ffi to see if it works, because webview_deno is using prebuilt binaries with deno's built-in ffi api, that's a very popular project for deno and we should follow it.

@JoCat
Copy link
Author

JoCat commented Nov 5, 2024

I think it's worth a try 😉

@JoCat
Copy link
Author

JoCat commented Nov 5, 2024

Let me briefly describe my situation. I am trying to create an Electron analog, but in a slightly different form - nodejs + webview. I also want to build it with node-sea if possible. And here I ran into this problem: the .node files are “lost” during the build.
image

I tried to package with bpkg, but that makes the build platform-dependent, which I probably don't need to do if I had pre-built binaries. And it would also allow to build an application for 3 different operating systems (Win, Mac, Linux) on one (as it works with the pkg module example).

@Winterreisender
Copy link
Owner

TLDR: I decided make pre-build .node binaries. I only found out an hour ago that this is possible.

It seems that the packager resolve the relative path of .node files in a wrong way. Since node sea is an experimental feature, I think, maybe ...... it's not a good time to fix it before it becomes stable.

And after thinks for a long time, I decide to keep using Node-API to build .node files and try to distribute pre-built .node files. Yes, I only knew it is possible one hour ago.

And I finally decided not to follow webview-bun and webview-deno to make pre-built .dll,.so. The reason is, well, there's still no reliable ffi libary for Node.js I can find for webview. I have to say that Node.js really falls behind Bun and Deno in FFI which makes webview-nodejs can only distribute pre-built .node files instead of more common used .dll,.so.

@Winterreisender Winterreisender self-assigned this Feb 5, 2025
@Winterreisender Winterreisender added this to the 0.6 milestone Feb 5, 2025
@JoCat
Copy link
Author

JoCat commented Feb 5, 2025

As far as I remember, .node files are the same .dll and .so, just renamed. I've now come to the point where I'm writing a wrapper for my project that uses wry and tao (tauri libraries) under the hood to create windows for nodejs. And I'm building it using napi-rs. You might find this option suitable for you.

@JoCat
Copy link
Author

JoCat commented Feb 5, 2025

And about the node sea - yes, I didn't notice that right away. In this case you can use bpkg, it will package .node files in base64 and load them into runtime. But in my case it doesn't work because it requires modification, and it's probably easier to write a plugin for esbuild (I use it in my project), which will put the .node files next to the program executable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants