Closed Xsmael closed 9 months ago
Diffing your package.json
with the current one in this repo doesn't show anything that would cause this issue:
The key trick to how this works is the "strippedProperties"
includes "devDependencies"
. So when copying the package.json
into the dist\app-name-version-number-os-arch
folder, it will produce a new package.json
file that does not even include a devDependencies
section in it. It then runs an npm install
and that will only install the dependencies
(because there won't be any devDependencies
in the file).
You should delete your dist
folder and run a build and then investigate the package.json
that was created.
You are also including some items in the dependencies
section that will likely be bundled by Vite, they don't need to be npm installed and sent with your distribution:
@vuepic/vue-datepicker
axios
(unless used by Node too)vue-image-lightbox
vue-router
Those are just the ones I am familiar with, the others may be able to be moved to devDeps too. You should experiment with that too. However, this will likely only reduce the package size by a few megabytes.
Thank you for these details! i didn't even understand this process!
ok did what you suggested and indeed the package.json
from dist
is clean:
{
"name": "HOTELN",
"version": "1.0.1",
"main": "http://localhost:4185",
"node-remote": "http://localhost:4185",
"node-main": "server.js",
"window": {
"width": 960,
"height": 600,
"min_width": 700,
"min_height": 500,
"icon": "dist-vue/icon.png"
},
"private": true,
"dependencies": {
"@vuepic/vue-datepicker": "^7.2.0",
"axios": "^1.5.0",
"express": "^4.18.2",
"flowbite": "^1.8.1",
"flowbite-vue": "0.0.17-next.2",
"json-2-csv": "^4.1.0",
"localStorage": "^1.0.4",
"noogger": "^0.1.8",
"vue-image-lightbox": "^7.2.0",
"vue-router": "^4.2.4"
},
"chromium-args": "--enable-spell-checking"
}
no devDependencies
however node_modules
from dist
has 631 folders which is the exact same number of folders in the main node_modules
and both weighs 600Mo roughly so, now i'm convinced that devDependencies are getting there somehow.
Also in dist
i renamed node_modules
and performed the npm install
myself which resulted in only 175 folders.
But i wonder what's wrong now.
You are also including some items in the dependencies section that will likely be bundled by Vite, they don't need to be npm installed and sent with your distribution:
@vuepic/vue-datepicker axios (unless used by Node too) vue-image-lightbox vue-router
About that, i don't understand; i'm using vue-datepicker component which provides me with UI component of a datepicker that i used for selecting date rages in my app. If i move it to devDependencies, will it still work in the bundled app ? I've also made routes and using vue router to navigate through them( yes i know its a desktop app, but the router just helps me to keep things orginised) so can I still move it ? same for axios, I do API calls with it to load json data.
Maybe there is something i missed.
By the way, i also notice the locales
folder which seems to be generated by the builder has about 114 files for 74Mb I guess these are language translations but i wonder for what? anyways, is there way to just select the locales that i wan't and save some more space ?
When you do npm run build:vue
, it will build just your Vue.js app (for web, not for desktop). Everything required to make your app run on the web will be included in the bundle that Vite produces (in ./dist-vue
). So the only dependencies you need to ship with your application are the ones that Vite will not include in it's bundle (the stuff specifically used by Node.js, like express
).
Are you checking the ./dist/HOTELN-1.0.1-win-x86/node_modules
folder, that is the folder that should be created with just the dependencies.
When you do npm run build
it will do the Vue build first (npm run build:vue
) then use the bundle Vite made in your desktop package (npm run build:nw
).
For the locales question:
Alright, sorry for the unclarity
Are you checking the ./dist/HOTELN-1.0.1-win-x86/node_modules folder, that is the folder that should be created with just the dependencies.
Yes!
Whenever i mentionned node_modules
from dist
i was in fact talking about ./dist/HOTELN-1.0.1-win-x86/node_modules
So i compared ./dist/HOTELN-1.0.1-win-x86/node_modules
with the main node_modules
and they looked pretty much the same meaning that devDependencies followed despite ./dist/HOTELN-1.0.1-win-x86/package.json
having none.
After the previous tests, cleaned everything and tried again, and now i have 220 folders in ./dist/HOTELN-1.0.1-win-x86/node_modules
instead of 631 which is much better but still more than what i get when i do npm install
manually. Also it is surprising, is there any caching mechanism in the process ? because i litteraly changed nothing. Apart from running npm install
manually, deleting everything and running the builder again.
For the locales i checked the link, it appears to me that i have to manually remove the files before running the script to create the installer, i thought there would be some option to specify in packaje.json or the CLI. If that's the only way, then it's fine.
You can try npm cache clean --force
. Removing of locales can crash your app, so it is not built in to the build tool. Be sure to read all of that post.
You can try
npm cache clean --force
. Removing of locales can crash your app, so it is not built in to the build tool. Be sure to read all of that post.
Alright, thanks for all. Yeah I did read about the risks too, no worries 👍
I don't know what happened, but only my first build worked nicely, after that any subsequent build is way too larage (300+ Mb) and when i checked i noticed the node_modules folder was the culprit, and i also noticed that pretty much all devDependencies are included, which is not the default behaviour, i also check my package.json, but can't see what's wrong. here it is:
Any idea ?