Do you bundle your JS files for performance?



In light of this tweet I was wondering if and how any of you bundle the JS files that make up your Electron app:

I’ve looked around and I haven’t been able to find much more info on how to do this. Bundlers are generally designed to work with browser-based code. And Googling returns a bunch of info on “electron packaging”, which is a different thing.



Electron can be used just like a browser (create BrowserWindow, point it at an HTML file that links to JavaScript, done), so the standard bundling setups can be used for most of the application code (what runs inside the renderer processes).


Right, just realized webpack has a special target for electron (two actually):

So that’s straightforward enough.

I’m still wondering how many devs with Electron apps in production actually do this.


The issue is that some bundlers replace core node modules with browser-friendly versions, which can lead to unexpected behavior.

In Electron Renderer you’re neither in pure browser environment or pure node environment. So it requires some consideration before using a bundler. Glad to find webpack has us covered.