Packaging and Distributing, Node Modules?


#1

Hey All,

So I am unsure what the best practices are for packaging and preparing your app for distribution. Are you supposed to pack your node modules into the app.asar? Wouldn’t that make the project rather large file size? Are there any guidelines/ best practices/ tutorials out there to go over this?

Thanks in advance!


#2

Good question, I have the same. I just used the https://github.com/maxogden/electron-packager to create my app, because I didn’t understand the other instructions, but now my app is 117 MB, which is a bit crazy for what it’s trying to accomplish.

I’m curious how to make this download smaller? Is there any way to find nodejs modules which I can exclude or remove?


#3

I did not know about the electron packager but I am seeing a similar result. I didn’t know if there were guidelines for making your app as lightweight as possible.


#4

It’s been a while since I’ve played around with Electron. But keep in mind that as part of the package it has to include Chromium and Node.js. This is going to take some minimum amount of space.


#5

electron-packager has a --prune option which will remove devDependencies from your packaged app but even the smallest Electron application is nearly 100mb.


#6

Thanks, I just want to make sure that I am not doing something terribly wrong, sounds like I am on track. Thanks all.


#7

I’m in the same boat. Simple apps weighing in well over 100mb. It would be nice if there were a way to make it strip out unneeded functionality to reduce file size. Understood though that its bundling node and chrome in with it… Just wishing…


#8

I used electron builder and my dmg total size is 37.5 MB. Have you tried it? I was using electron version 0.37.8.


#9

Electron itself is ~30 some odd MB so if your app is much larger you should look at what you are are requiring and building along with your app. If it is for testing or development and not needed in production use --prune with electron-packager to skip it in your final package. You can also use --ignore to skip files/dirs you don’t need.


#10

When you use electron-packager, within the contents of the .app, the Electron Framework.framework file/container is 113MB so, its not the user’s code. I just made a VERY simple app with not much in it, ran it through electron packager and its 130MB. The app folder under Resources is 12MB. The rest of stuff with electron so… its not user code making it so large.


#11

Also, if you dig down in that… the Electron Framework binary isn’t ~30MB, its 69.5MB. Then add the node library within it, ffmpeg, and other stuff…


#12

On Mac at least, the electron framework is 109.4MB, which is pretty crazy…:

Within there:

  • Electron framework binary: 66.6MB
  • Resources: 22.1MB
    • icudtl.dat: 10.2MB
    • content_shell.pak: 9.5MB
    • (Others: ~2MB)
  • Libraries: 20.8MB
    • libnode.dylib: 18.2MB
    • libffmpeg.dylib: 2.6MB

#13

What version are you using? I think I was using the most current version (on Mac as well) and mine was, as mentioned above, 113MB.


#14

I’m using Electron Prebuilt 0.37.8.


#15

Whoops, sorry, I meant zipped :package: — was echoing the previous statement that a very lightweight app could be < 40MB.


#16

(Bump) I wonder how straightforward it is to do your own custom build of Electron, and trim it down?

Edit: Ideally, I’d love to be able to generate a custom build of Electron simply by toggling features on and off, so I can slim it down as far as possible.