Compile Electron into a library?


Is there a way to build Electron into a library instead of .exe on Windows?

We are looking to incorporate Electron into our existing WPF application on Windows and slowly move the codebase over to an HTML UI. The eventual goal is to become an normal Electron app, but it is going to take us several releases. I have been able to vet out the integration aspects and things are looking good. But it would be a lot easier to incorporate Electron into our existing app and auto test infrastructure if Electron was a library that we could load and then call “start” from a thread that Electron could take ownership of.


There’s a library side of Electron. On its own, it’s known as Node.JS. The executable side is based on Chromium, specifically the JavaScript engine and the browser API. So no, you can’t get a perfect Electron experience without Electron itself, but any Node-based web app that uses modern browser API calls can be easily imported into Electron.


I do want all of Electron just built as a .dll instead of a .exe so that I can load it into my existing infrastructure. The DLL only needs one export that does what Main does today (I think).


That seems like a lot of work to undertake and I’m not sure what the benefit of it would be.

It would be a whole lot easier for you to migrate your app to being run in the browser and then install it into Electron, rather than trying to have Electron run as a subsidiary of some WPF thing.


It turns out that that building Electron into a library, at least on Windows, is pretty easy. I just changed the type to shared_Library in electron.gyp and changed WinMain in to be an exported function. You can then call the exported function from a .exe in any thread to run Electron.

I made a fork of Electron which shows this change just in case anyone has interest in doing the same.


It works charm but we also look for creating the screen in our application main window. How easy is it to get the Electron browser window to be created in our application window?


Are there any examples to use electron UI in C++ win32/cocoa applications?