feat(nsis): add an option to opt out tauri utils plugin
Add an option to replace nsis util plugin with built-in ones, this can reduce the final bundle size by ~0.8 MB
Downsides including:
- Can't compare semver like
2.0.0-alpha.1 - No Windows 7 support when using downloadBootstrapper option due to Windows 7 ~~doesn't have curl installed by default~~ doesn't have tls 1.2 enabled by default (this option is not recommended for Windows 7 anyway)
I need to take a look at the CheckIfAppIsRunning part, it's not actually detecting the app right now
I need to take a look at the CheckIfAppIsRunning part, it's not actually detecting the app right now
Should be fixed now
I still would like to explore reducing the size of our semverCompare and process utils, I believe we can probably make these two plugins really small that we wouldn't need to use the alternatives.
I compiled it without the download one, it's around 200 KB, not too bad but definitely something we could improve
I still would like to explore reducing the size of our semverCompare and process utils, I believe we can probably make these two plugins really small that we wouldn't need to use the alternatives.
I compiled it without the download one, it's around 200 KB, not too bad but definitely something we could improve
A 100kb of that are related to static CRT iirc
Sorry for the long delay, I wanted to experiment a bit and see if we can avoid having this option.
I have been doing some experiments and I have managed to reduce the size of some of our nsis plugins:
| nsis-semvercompare | nsis-process | nsis-semvercompare & nsis-process combined in one DLL | |
|---|---|---|---|
| dev | 198kb | 208kb | 200kb |
| no_std | 35kb | 48kb | 53kb |
| no_std (UPX) | 20kb | 26kb | 29kb |
So I think we can keep using our nsis-process and nsis-semvercompare without compromising while keeping the size very small.
The remaining bit here is the nsis-download plugin which is the most bloated of them all and unfortunately can't be written in a no_std environment, at least without too much work.
So I am proposing to remove it all together and use powershell to download the bootstrapper, this means it will fail on Windows7 and so we will need to recommend users to use embedBootstrapper when targeting Windows7.
If that's not desired, we can make this PR add an opt-out option specifically for the nsis-download plugin.
cc @lucasfernog @FabianLars
I think requiring embedBootstrapper for windows 7 is fine. We shouldn't do more than the minimum for win7 at this point imo (and remove support for it in v3).
One thing though, i am fairlyyy sure i've had issues without our download plugin on win10 too so we should triple check it! We should also check if using powershell will open a terminal window again which tbh would be a blocker for me too.
One thing though, i am fairlyyy sure i've had issues without our download plugin on win10 too so we should triple check it! We should also check if using powershell will open a terminal window again which tbh would be a blocker for me too.
using nsExec::Exec with PowerShell.exe -WindowStyle hidden should not show it.
But the one thing I hate about this is that we lose the progress bar.
no std version seem to be promising, 50 KB is acceptable
To be honest, if we can't reduce the download plugin's size enough, there'll not be much benefit doing it this way, the bootstrap is only 1.5 MB
using nsExec::Exec with PowerShell.exe -WindowStyle hidden should not show it.
I'm pretty sure nsExec::Exec powershell -Command alone creates a hidden window
The problem i am thinking about is that when ms terminal is the default console host then the hidden window style doesn't work anymore. On win11 this isn't a problem as long as we're only downloading webview2 since all win11 installations should have that, but win10 added support for changing the default to ms terminal in later versions too and there we can't expect webview2 to be installed.
I'm pretty sure nsExec::Exec powershell -Command will create a hidden window even when you set windows terminal as default console host, I have tested this on my machine (windows 10) as least
I have been tinkering over the weekend a bit and I managed to get the dlls even smaller
| nsis-semvercompare | nsis-process | nsis-semvercompare & nsis-process combined in one DLL | |
|---|---|---|---|
| dev | 198kb | 208kb | 200kb |
| no_std | 35kb | 48kb | 53kb |
| no_std+upx | 20kb | 26kb | 29kb |
| no_std/no_msvcrt | 10kb | 22kb | 27kb |
| no_std/no_msvcrt+upx | 7kb | 13kb | 16kb |
I don't think I can get them smaller than this, so I will start looking into the download plugin
I don't know how I missed this before but looks like nsis has a built-in download plugin that is able to download the webview2 installer which is also really small in size
I apologize for initially asking you to open this PR then rejecting it. I have opened https://github.com/tauri-apps/nsis-tauri-utils/pull/26 for the small dll size
I don't know how I missed this before but looks like nsis has a built-in download plugin that is able to download the webview2 installer which is also really small in size
Its first line says
This built-in plugin allows you to download files via HTTP (but not HTTPS).
I did come across this but it says no HTTPS
I apologize for initially asking you to open this PR then rejecting it.
It's fine, glad to accept a better solution 😃
I did come across this but it says no HTTPS
That's probably why it works on win7 because https will fail, though i am surprised a http request against a https url works, probably only a matter of time until this breaks so we should keep an eye on it.