webview-nodejs icon indicating copy to clipboard operation
webview-nodejs copied to clipboard

Pre-built binaries

Open JoCat opened this issue 1 year ago • 6 comments

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.

JoCat avatar Nov 01 '24 22:11 JoCat

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.

Winterreisender avatar Nov 02 '24 02:11 Winterreisender

I think it's worth a try 😉

JoCat avatar Nov 05 '24 21:11 JoCat

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).

JoCat avatar Nov 05 '24 22:11 JoCat

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 avatar Feb 05 '25 15:02 Winterreisender

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 avatar Feb 05 '25 19:02 JoCat

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.

JoCat avatar Feb 05 '25 19:02 JoCat